Image encoding/decoding method and device for performing prediction, and method for transmitting bitstream involving weighted prediction and bi-directional optical flow

ABSTRACT

An image encoding/decoding method and apparatus are provided. An image decoding method according to the present disclosure is performed by an image decoding apparatus. The image decoding method comprises deriving a first flag specifying whether to perform weighted prediction on a current block and a weight index BcwIdx of bi-prediction with CU-level weight (BCW) for the current block, determining whether to perform default weighted prediction or explicit weighted prediction on the current block based on the first flag and BcwIdx, and generating a prediction block for the current block by performing the determined method.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. application Ser. No.17/677,410, filed on Feb. 22, 2022, which is a continuation pursuant to35 U.S.C. § 119(e) of International Application PCT/KR2020/011103, withan international filing date of Aug. 20, 2020, which claims the benefitof U.S. Provisional Patent Application No. 62/890,573, filed on Aug. 22,2019, the contents of these prior applications are hereby incorporatedby reference herein in their entirety.

TECHNICAL FIELD

The present disclosure relates to an image encoding/decoding method andapparatus and a method of transmitting a bitstream, and, moreparticularly, to an image encoding/decoding method and apparatus forperforming weighted prediction in consideration of prediction refinementwith optical flow (PROF), and a method of transmitting a bitstreamgenerated by the image encoding method/apparatus of the presentdisclosure.

BACKGROUND ART

Recently, demand for high-resolution and high-quality images such ashigh definition (HD) images and ultra high definition (UHD) images isincreasing in various fields. As resolution and quality of image dataare improved, the amount of transmitted information or bits relativelyincreases as compared to existing image data. An increase in the amountof transmitted information or bits causes an increase in transmissioncost and storage cost.

Accordingly, there is a need for high-efficient image compressiontechnology for effectively transmitting, storing and reproducinginformation on high-resolution and high-quality images.

DISCLOSURE Technical Problem

An object of the present disclosure is to provide an imageencoding/decoding method and apparatus with improved encoding/decodingefficiency.

Another object of the present disclosure is to provide an imageencoding/decoding method and apparatus for performing weightedprediction.

Another object of the present disclosure is to provide an imageencoding/decoding method and apparatus for performing weightedprediction or bi-prediction with CU-level weight (BCW) in considerationof PROF.

Another object of the present disclosure is to provide a method oftransmitting a bitstream generated by an image encoding method orapparatus according to the present disclosure.

Another object of the present disclosure is to provide a recordingmedium storing a bitstream generated by an image encoding method orapparatus according to the present disclosure.

Another object of the present disclosure is to provide a recordingmedium storing a bitstream received, decoded and used to reconstruct animage by an image decoding apparatus according to the presentdisclosure.

The technical problems solved by the present disclosure are not limitedto the above technical problems and other technical problems which arenot described herein will become apparent to those skilled in the artfrom the following description.

Technical Solution

An image decoding method according to an aspect of the presentdisclosure may comprise deriving a first flag specifying whether toperform weighted prediction on a current block and a weight index BcwIdxof bi-prediction with CU-level weight (BCW) for the current block,determining whether to perform default weighted prediction or explicitweighted prediction on the current block based on the first flag andBcwIdx, and generating a prediction block for the current block byperforming the determined method.

In the image decoding method according to the present disclosure, thefirst flag may be differently determined based on a slice type of acurrent slice, to which the current block belongs.

In the image decoding method according to the present disclosure, thefirst flag may be derived as a value of pps_weighted_pred_flag signaledat a picture parameter set (PPS), based on the slice type of the currentslice being a P slice, and the first flag may be derived as a value ofpps_weighted_bipred_flag signaled at the PPS, based on the slice type ofthe current slice being a B slice.

In the image decoding method according to the present disclosure, BcwIdxmay be derived based on a syntax element bcw_idx signaled through abitstream, and BcwIdx may be derived as 0 based on bcw_idx being notpresent in the bitstream.

In the image decoding method according to the present disclosure,bcw_idx may be parsed from the bitstream based on a weighted predictionflag of a reference picture of the current block.

In the image decoding method according to the present disclosure,bcw_idx may be parsed from the bitstream based on all weightedprediction flags of a reference picture of the current block being 0.

In the image decoding method according to the present disclosure,default weighted prediction may be performed on the current block, basedon the first flag being 0 or BcwIdx being not 0.

In the image decoding method according to the present disclosure,explicit weighted prediction may be performed on the current block,based on the first flag being 1 or BcwIdx being 0.

In the image decoding method according to the present disclosure, thedefault weighted prediction may perform BCW or average sum based onBcwIdx.

In the image decoding method according to the present disclosure,average sum may be performed on the current block based on BcwIdx being0, and BCW may be performed on the current block based on BcwIdx beingnot 0.

In the image decoding method according to the present disclosure, theexplicit weighted prediction may be performed based on weightingparameters (weight and offset) for a reference picture of the currentblock.

In the image decoding method according to the present disclosure, theweighting parameters may be explicitly signaled through a bitstream.

An image decoding apparatus according to another aspect of the presentdisclosure may comprise a memory and at least one processor. The atleast one processor may derive a first flag specifying whether toperform weighted prediction on a current block and a weight index BcwIdxof bi-prediction with CU-level weight (BCW) for the current block,determine whether to perform default weighted prediction or explicitweighted prediction on the current block based on the first flag andBcwIdx, and generate a prediction block for the current block byperforming the determined method.

An image encoding method according to another aspect of the presentdisclosure may comprise determining a first flag specifying whether toperform weighted prediction on a current block and a weight index BcwIdxof bi-prediction with CU-level weight (BCW) for the current block,determining whether to perform default weighted prediction or explicitweighted prediction on the current block based on the first flag andBcwIdx, and generating a prediction block for the current block byperforming the determined method.

In addition, a computer-readable recording medium according to anotheraspect of the present disclosure may store the bitstream generated bythe image encoding apparatus or the image encoding method of the presentdisclosure.

The features briefly summarized above with respect to the presentdisclosure are merely exemplary aspects of the detailed descriptionbelow of the present disclosure, and do not limit the scope of thepresent disclosure.

Advantageous Effects

According to the present disclosure, it is possible to provide an imageencoding/decoding method and apparatus with improved encoding/decodingefficiency.

Also, according to the present disclosure, it is possible to provide animage encoding/decoding method and apparatus for performing weightedprediction.

Also, according to the present disclosure, it is possible to provide animage encoding/decoding method and apparatus for performing weightedprediction or bi-prediction with CU-level weight (BCW) in considerationof PROF.

Also, according to the present disclosure, it is possible to provide amethod of transmitting a bitstream generated by an image encoding methodor apparatus according to the present disclosure.

Also, according to the present disclosure, it is possible to provide arecording medium storing a bitstream generated by an image encodingmethod or apparatus according to the present disclosure.

Also, according to the present disclosure, it is possible to provide arecording medium storing a bitstream received, decoded and used toreconstruct an image by an image decoding apparatus according to thepresent disclosure.

It will be appreciated by persons skilled in the art that that theeffects that can be achieved through the present disclosure are notlimited to what has been particularly described hereinabove and otheradvantages of the present disclosure will be more clearly understoodfrom the detailed description.

DESCRIPTION OF DRAWINGS

FIG. 1 is a view schematically illustrating a video coding system, towhich an embodiment of the present disclosure is applicable.

FIG. 2 is a view schematically illustrating an image encoding apparatus,to which an embodiment of the present disclosure is applicable.

FIG. 3 is a view schematically illustrating an image decoding apparatus,to which an embodiment of the present disclosure is applicable.

FIG. 4 is a flowchart illustrating an inter prediction based video/imageencoding method.

FIG. 5 is a view illustrating the configuration of an inter predictionunit 180 according to the present disclosure.

FIG. 6 is a flowchart illustrating an inter prediction based video/imagedecoding method.

FIG. 7 is a view illustrating the configuration of an inter predictionunit 260 according to the present disclosure.

FIG. 8 is a view illustrating neighboring blocks available as a spatialmerge candidate.

FIG. 9 is a view schematically illustrating a merge candidate listconstruction method according to an example of the present disclosure.

FIG. 10 is a view illustrating a candidate pair for redundancy checkperformed on a spatial candidate.

FIG. 11 is a view illustrating a method of scaling a motion vector of atemporal candidate.

FIG. 12 is a view illustrating a position where a temporal candidate isderived.

FIG. 13 is a view schematically illustrating a motion vector predictorcandidate list configuration method according to an example of thepresent disclosure.

FIG. 14 is a view illustrating a parameter model of an affine mode.

FIG. 15 is a view illustrating a method of generating an affine mergecandidate list.

FIG. 16 is a view illustrating a CPMV derived from a neighboring block.

FIG. 17 is a view illustrating neighboring blocks for deriving aconstructed affine merge candidate.

FIG. 18 is a view illustrating a method of generating an affine MVPcandidate list.

FIG. 19 is a view illustrating a neighboring block of a sub-block basedTMVP mode.

FIG. 20 is a view illustrating a method of deriving a motion vectorfield according to a sub-block based TMVP mode.

FIG. 21 is a view illustrating a CU extended to perform BDOF.

FIG. 22 is a view illustrating a relationship among Δv(i,j), v(i,j) anda subblock motion vector.

FIG. 23 is a flowchart illustrating an example of performing PROF, BCW,WP and/or average sum according to the present disclosure.

FIG. 24 is a flowchart illustrating another example of performing PROF,BCW, WP and/or average sum according to the present disclosure.

FIG. 25 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 7.

FIG. 26 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 8.

FIG. 27 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 9.

FIG. 28 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 10.

FIG. 29 is a flowchart illustrating an example of performing BDOF, PROF,BCW, WP, and/or average sum according to the present disclosure.

FIG. 30 is a view showing a content streaming system, to which anembodiment of the present disclosure is applicable.

MODE FOR INVENTION

Hereinafter, the embodiments of the present disclosure will be describedin detail with reference to the accompanying drawings so as to be easilyimplemented by those skilled in the art. However, the present disclosuremay be implemented in various different forms, and is not limited to theembodiments described herein.

In describing the present disclosure, if it is determined that thedetailed description of a related known function or construction rendersthe scope of the present disclosure unnecessarily ambiguous, thedetailed description thereof will be omitted. In the drawings, parts notrelated to the description of the present disclosure are omitted, andsimilar reference numerals are attached to similar parts.

In the present disclosure, when a component is “connected”, “coupled” or“linked” to another component, it may include not only a directconnection relationship but also an indirect connection relationship inwhich an intervening component is present. In addition, when a component“includes” or “has” other components, it means that other components maybe further included, rather than excluding other components unlessotherwise stated.

In the present disclosure, the terms first, second, etc. may be usedonly for the purpose of distinguishing one component from othercomponents, and do not limit the order or importance of the componentsunless otherwise stated. Accordingly, within the scope of the presentdisclosure, a first component in one embodiment may be referred to as asecond component in another embodiment, and similarly, a secondcomponent in one embodiment may be referred to as a first component inanother embodiment.

In the present disclosure, components that are distinguished from eachother are intended to clearly describe each feature, and do not meanthat the components are necessarily separated. That is, a plurality ofcomponents may be integrated and implemented in one hardware or softwareunit, or one component may be distributed and implemented in a pluralityof hardware or software units. Therefore, even if not stated otherwise,such embodiments in which the components are integrated or the componentis distributed are also included in the scope of the present disclosure.

In the present disclosure, the components described in variousembodiments do not necessarily mean essential components, and somecomponents may be optional components. Accordingly, an embodimentconsisting of a subset of components described in an embodiment is alsoincluded in the scope of the present disclosure. In addition,embodiments including other components in addition to componentsdescribed in the various embodiments are included in the scope of thepresent disclosure.

The present disclosure relates to encoding and decoding of an image, andterms used in the present disclosure may have a general meaning commonlyused in the technical field, to which the present disclosure belongs,unless newly defined in the present disclosure.

In the present disclosure, a “picture” generally refers to a unitrepresenting one image in a specific time period, and a slice/tile is acoding unit constituting a part of a picture, and one picture may becomposed of one or more slices/tiles. In addition, a slice/tile mayinclude one or more coding tree units (CTUs).

In the present disclosure, a “pixel” or a “pel” may mean a smallest unitconstituting one picture (or image). In addition, “sample” may be usedas a term corresponding to a pixel. A sample may generally represent apixel or a value of a pixel, and may represent only a pixel/pixel valueof a luma component or only a pixel/pixel value of a chroma component.

In the present disclosure, a “unit” may represent a basic unit of imageprocessing. The unit may include at least one of a specific region ofthe picture and information related to the region. The unit may be usedinterchangeably with terms such as “sample array”, “block” or “area” insome cases. In a general case, an M×N block may include samples (orsample arrays) or a set (or array) of transform coefficients of Mcolumns and N rows.

In the present disclosure, “current block” may mean one of “currentcoding block”, “current coding unit”, “coding target block”, “decodingtarget block” or “processing target block”. When prediction isperformed, “current block” may mean “current prediction block” or“prediction target block”. When transform (inversetransform)/quantization (dequantization) is performed, “current block”may mean “current transform block” or “transform target block”. Whenfiltering is performed, “current block” may mean “filtering targetblock”.

In the present disclosure, the term “/” and “,” should be interpreted toindicate “and/or.” For instance, the expression “A/B” and “A, B” maymean “A and/or B.” Further, “A/B/C” and “A/B/C” may mean “at least oneof A, B, and/or C.”

In the present disclosure, the term “or” should be interpreted toindicate “and/or.” For instance, the expression “A or B” may comprise 1)only “A”, 2) only “B”, and/or 3) both “A and B”. In other words, in thepresent disclosure, the term “or” should be interpreted to indicate“additionally or alternatively.”

Overview of Video Coding System

FIG. 1 is a view showing a video coding system according to the presentdisclosure.

The video coding system according to an embodiment may include aencoding apparatus 10 and a decoding apparatus 20. The encodingapparatus 10 may deliver encoded video and/or image information or datato the decoding apparatus 20 in the form of a file or streaming via adigital storage medium or network.

The encoding apparatus 10 according to an embodiment may include a videosource generator 11, an encoding unit 12 and a transmitter 13. Thedecoding apparatus 20 according to an embodiment may include a receiver21, a decoding unit 22 and a renderer 23. The encoding unit 12 may becalled a video/image encoding unit, and the decoding unit 22 may becalled a video/image decoding unit. The transmitter 13 may be includedin the encoding unit 12. The receiver 21 may be included in the decodingunit 22. The renderer 23 may include a display and the display may beconfigured as a separate device or an external component.

The video source generator 11 may acquire a video/image through aprocess of capturing, synthesizing or generating the video/image. Thevideo source generator 11 may include a video/image capture deviceand/or a video/image generating device. The video/image capture devicemay include, for example, one or more cameras, video/image archivesincluding previously captured video/images, and the like. Thevideo/image generating device may include, for example, computers,tablets and smartphones, and may (electronically) generate video/images.For example, a virtual video/image may be generated through a computeror the like. In this case, the video/image capturing process may bereplaced by a process of generating related data.

The encoding unit 12 may encode an input video/image. The encoding unit12 may perform a series of procedures such as prediction, transform, andquantization for compression and coding efficiency. The encoding unit 12may output encoded data (encoded video/image information) in the form ofa bitstream.

The transmitter 13 may transmit the encoded video/image information ordata output in the form of a bitstream to the receiver 21 of thedecoding apparatus 20 through a digital storage medium or a network inthe form of a file or streaming. The digital storage medium may includevarious storage mediums such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, andthe like. The transmitter 13 may include an element for generating amedia file through a predetermined file format and may include anelement for transmission through a broadcast/communication network. Thereceiver 21 may extract/receive the bitstream from the storage medium ornetwork and transmit the bitstream to the decoding unit 22.

The decoding unit 22 may decode the video/image by performing a seriesof procedures such as dequantization, inverse transform, and predictioncorresponding to the operation of the encoding unit 12.

The renderer 23 may render the decoded video/image. The renderedvideo/image may be displayed through the display.

Overview of Image Encoding Apparatus

FIG. 2 is a view schematically showing an image encoding apparatus, towhich an embodiment of the present disclosure is applicable.

As shown in FIG. 2 , the image encoding apparatus 100 may include animage partitioner 110, a subtractor 115, a transformer 120, a quantizer130, a dequantizer 140, an inverse transformer 150, an adder 155, afilter 160, a memory 170, an inter prediction unit 180, an intraprediction unit 185 and an entropy encoder 190. The inter predictionunit 180 and the intra prediction unit 185 may be collectively referredto as a “prediction unit”. The transformer 120, the quantizer 130, thedequantizer 140 and the inverse transformer 150 may be included in aresidual processor. The residual processor may further include thesubtractor 115.

All or at least some of the plurality of components configuring theimage encoding apparatus 100 may be configured by one hardware component(e.g., an encoder or a processor) in some embodiments. In addition, thememory 170 may include a decoded picture buffer (DPB) and may beconfigured by a digital storage medium.

The image partitioner 110 may partition an input image (or a picture ora frame) input to the image encoding apparatus 100 into one or moreprocessing units. For example, the processing unit may be called acoding unit (CU). The coding unit may be acquired by recursivelypartitioning a coding tree unit (CTU) or a largest coding unit (LCU)according to a quad-tree binary-tree ternary-tree (QT/BT/TT) structure.For example, one coding unit may be partitioned into a plurality ofcoding units of a deeper depth based on a quad tree structure, a binarytree structure, and/or a ternary structure. For partitioning of thecoding unit, a quad tree structure may be applied first and the binarytree structure and/or ternary structure may be applied later. The codingprocedure according to the present disclosure may be performed based onthe final coding unit that is no longer partitioned. The largest codingunit may be used as the final coding unit or the coding unit of deeperdepth acquired by partitioning the largest coding unit may be used asthe final coding unit. Here, the coding procedure may include aprocedure of prediction, transform, and reconstruction, which will bedescribed later. As another example, the processing unit of the codingprocedure may be a prediction unit (PU) or a transform unit (TU). Theprediction unit and the transform unit may be split or partitioned fromthe final coding unit. The prediction unit may be a unit of sampleprediction, and the transform unit may be a unit for deriving atransform coefficient and/or a unit for deriving a residual signal fromthe transform coefficient.

The prediction unit (the inter prediction unit 180 or the intraprediction unit 185) may perform prediction on a block to be processed(current block) and generate a predicted block including predictionsamples for the current block. The prediction unit may determine whetherintra prediction or inter prediction is applied on a current block or CUbasis. The prediction unit may generate various information related toprediction of the current block and transmit the generated informationto the entropy encoder 190. The information on the prediction may beencoded in the entropy encoder 190 and output in the form of abitstream.

The intra prediction unit 185 may predict the current block by referringto the samples in the current picture. The referred samples may belocated in the neighborhood of the current block or may be located apartaccording to the intra prediction mode and/or the intra predictiontechnique. The intra prediction modes may include a plurality ofnon-directional modes and a plurality of directional modes. Thenon-directional mode may include, for example, a DC mode and a planarmode. The directional mode may include, for example, 33 directionalprediction modes or 65 directional prediction modes according to thedegree of detail of the prediction direction. However, this is merely anexample, more or less directional prediction modes may be used dependingon a setting. The intra prediction unit 185 may determine the predictionmode applied to the current block by using a prediction mode applied toa neighboring block.

The inter prediction unit 180 may derive a predicted block for thecurrent block based on a reference block (reference sample array)specified by a motion vector on a reference picture. In this case, inorder to reduce the amount of motion information transmitted in theinter prediction mode, the motion information may be predicted in unitsof blocks, subblocks, or samples based on correlation of motioninformation between the neighboring block and the current block. Themotion information may include a motion vector and a reference pictureindex. The motion information may further include inter predictiondirection (L0 prediction, L1 prediction, Bi-prediction, etc.)information. In the case of inter prediction, the neighboring block mayinclude a spatial neighboring block present in the current picture and atemporal neighboring block present in the reference picture. Thereference picture including the reference block and the referencepicture including the temporal neighboring block may be the same ordifferent. The temporal neighboring block may be called a collocatedreference block, a co-located CU (colCU), and the like. The referencepicture including the temporal neighboring block may be called acollocated picture (colPic). For example, the inter prediction unit 180may configure a motion information candidate list based on neighboringblocks and generate information indicating which candidate is used toderive a motion vector and/or a reference picture index of the currentblock. Inter prediction may be performed based on various predictionmodes. For example, in the case of a skip mode and a merge mode, theinter prediction unit 180 may use motion information of the neighboringblock as motion information of the current block. In the case of theskip mode, unlike the merge mode, the residual signal may not betransmitted. In the case of the motion vector prediction (MVP) mode, themotion vector of the neighboring block may be used as a motion vectorpredictor, and the motion vector of the current block may be signaled byencoding a motion vector difference and an indicator for a motion vectorpredictor. The motion vector difference may mean a difference betweenthe motion vector of the current block and the motion vector predictor.

The prediction unit may generate a prediction signal based on variousprediction methods and prediction techniques described below. Forexample, the prediction unit may not only apply intra prediction orinter prediction but also simultaneously apply both intra prediction andinter prediction, in order to predict the current block. A predictionmethod of simultaneously applying both intra prediction and interprediction for prediction of the current block may be called combinedinter and intra prediction (CIIP). In addition, the prediction unit mayperform intra block copy (IBC) for prediction of the current block.Intra block copy may be used for content image/video coding of a game orthe like, for example, screen content coding (SCC). IBC is a method ofpredicting a current picture using a previously reconstructed referenceblock in the current picture at a location apart from the current blockby a predetermined distance. When IBC is applied, the location of thereference block in the current picture may be encoded as a vector (blockvector) corresponding to the predetermined distance.

The prediction signal generated by the prediction unit may be used togenerate a reconstructed signal or to generate a residual signal. Thesubtractor 115 may generate a residual signal (residual block orresidual sample array) by subtracting the prediction signal (predictedblock or prediction sample array) output from the prediction unit fromthe input image signal (original block or original sample array). Thegenerated residual signal may be transmitted to the transformer 120.

The transformer 120 may generate transform coefficients by applying atransform technique to the residual signal. For example, the transformtechnique may include at least one of a discrete cosine transform (DCT),a discrete sine transform (DST), a karhunen-loève transform (KLT), agraph-based transform (GBT), or a conditionally non-linear transform(CNT). Here, the GBT means transform obtained from a graph whenrelationship information between pixels is represented by the graph. TheCNT refers to transform acquired based on a prediction signal generatedusing all previously reconstructed pixels. In addition, the transformprocess may be applied to square pixel blocks having the same size ormay be applied to blocks having a variable size rather than square.

The quantizer 130 may quantize the transform coefficients and transmitthem to the entropy encoder 190. The entropy encoder 190 may encode thequantized signal (information on the quantized transform coefficients)and output a bitstream. The information on the quantized transformcoefficients may be referred to as residual information. The quantizer130 may rearrange quantized transform coefficients in a block form intoa one-dimensional vector form based on a coefficient scanning order andgenerate information on the quantized transform coefficients based onthe quantized transform coefficients in the one-dimensional vector form.

The entropy encoder 190 may perform various encoding methods such as,for example, exponential Golomb, context-adaptive variable length coding(CAVLC), context-adaptive binary arithmetic coding (CABAC), and thelike. The entropy encoder 190 may encode information necessary forvideo/image reconstruction other than quantized transform coefficients(e.g., values of syntax elements, etc.) together or separately. Encodedinformation (e.g., encoded video/image information) may be transmittedor stored in units of network abstraction layers (NALs) in the form of abitstream. The video/image information may further include informationon various parameter sets such as an adaptation parameter set (APS), apicture parameter set (PPS), a sequence parameter set (SPS), or a videoparameter set (VPS). In addition, the video/image information mayfurther include general constraint information. The signaledinformation, transmitted information and/or syntax elements described inthe present disclosure may be encoded through the above-describedencoding procedure and included in the bitstream.

The bitstream may be transmitted over a network or may be stored in adigital storage medium. The network may include a broadcasting networkand/or a communication network, and the digital storage medium mayinclude various storage media such as USB, SD, CD, DVD, Blu-ray, HDD,SSD, and the like. A transmitter (not shown) transmitting a signaloutput from the entropy encoder 190 and/or a storage unit (not shown)storing the signal may be included as internal/external element of theimage encoding apparatus 100. Alternatively, the transmitter may beprovided as the component of the entropy encoder 190.

The quantized transform coefficients output from the quantizer 130 maybe used to generate a residual signal. For example, the residual signal(residual block or residual samples) may be reconstructed by applyingdequantization and inverse transform to the quantized transformcoefficients through the dequantizer 140 and the inverse transformer150.

The adder 155 adds the reconstructed residual signal to the predictionsignal output from the inter prediction unit 180 or the intra predictionunit 185 to generate a reconstructed signal (reconstructed picture,reconstructed block, reconstructed sample array). If there is noresidual for the block to be processed, such as a case where the skipmode is applied, the predicted block may be used as the reconstructedblock. The adder 155 may be called a reconstructor or a reconstructedblock generator. The generated reconstructed signal may be used forintra prediction of a next block to be processed in the current pictureand may be used for inter prediction of a next picture through filteringas described below.

Meanwhile, as described below, luma mapping with chroma scaling (LMCS)is applicable in a picture encoding process.

The filter 160 may improve subjective/objective image quality byapplying filtering to the reconstructed signal. For example, the filter160 may generate a modified reconstructed picture by applying variousfiltering methods to the reconstructed picture and store the modifiedreconstructed picture in the memory 170, specifically, a DPB of thememory 170. The various filtering methods may include, for example,deblocking filtering, a sample adaptive offset, an adaptive loop filter,a bilateral filter, and the like. The filter 160 may generate variousinformation related to filtering and transmit the generated informationto the entropy encoder 190 as described later in the description of eachfiltering method. The information related to filtering may be encoded bythe entropy encoder 190 and output in the form of a bitstream.

The modified reconstructed picture transmitted to the memory 170 may beused as the reference picture in the inter prediction unit 180. Wheninter prediction is applied through the image encoding apparatus 100,prediction mismatch between the image encoding apparatus 100 and theimage decoding apparatus may be avoided and encoding efficiency may beimproved.

The DPB of the memory 170 may store the modified reconstructed picturefor use as a reference picture in the inter prediction unit 180. Thememory 170 may store the motion information of the block from which themotion information in the current picture is derived (or encoded) and/orthe motion information of the blocks in the picture that have alreadybeen reconstructed. The stored motion information may be transmitted tothe inter prediction unit 180 and used as the motion information of thespatial neighboring block or the motion information of the temporalneighboring block. The memory 170 may store reconstructed samples ofreconstructed blocks in the current picture and may transfer thereconstructed samples to the intra prediction unit 185.

Overview of Image Decoding Apparatus

FIG. 3 is a view schematically showing an image decoding apparatus, towhich an embodiment of the present disclosure is applicable.

As shown in FIG. 3 , the image decoding apparatus 200 may include anentropy decoder 210, a dequantizer 220, an inverse transformer 230, anadder 235, a filter 240, a memory 250, an inter prediction unit 260 andan intra prediction unit 265. The inter prediction unit 260 and theintra prediction unit 265 may be collectively referred to as a“prediction unit”. The dequantizer 220 and the inverse transformer 230may be included in a residual processor.

All or at least some of a plurality of components configuring the imagedecoding apparatus 200 may be configured by a hardware component (e.g.,a decoder or a processor) according to an embodiment. In addition, thememory 250 may include a decoded picture buffer (DPB) or may beconfigured by a digital storage medium.

The image decoding apparatus 200, which has received a bitstreamincluding video/image information, may reconstruct an image byperforming a process corresponding to a process performed by the imageencoding apparatus 100 of FIG. 2 . For example, the image decodingapparatus 200 may perform decoding using a processing unit applied inthe image encoding apparatus. Thus, the processing unit of decoding maybe a coding unit, for example. The coding unit may be acquired bypartitioning a coding tree unit or a largest coding unit. Thereconstructed image signal decoded and output through the image decodingapparatus 200 may be reproduced through a reproducing apparatus (notshown).

The image decoding apparatus 200 may receive a signal output from theimage encoding apparatus of FIG. 2 in the form of a bitstream. Thereceived signal may be decoded through the entropy decoder 210. Forexample, the entropy decoder 210 may parse the bitstream to deriveinformation (e.g., video/image information) necessary for imagereconstruction (or picture reconstruction). The video/image informationmay further include information on various parameter sets such as anadaptation parameter set (APS), a picture parameter set (PPS), asequence parameter set (SPS), or a video parameter set (VPS). Inaddition, the video/image information may further include generalconstraint information. The image decoding apparatus may further decodepicture based on the information on the parameter set and/or the generalconstraint information. Signaled/received information and/or syntaxelements described in the present disclosure may be decoded through thedecoding procedure and obtained from the bitstream. For example, theentropy decoder 210 decodes the information in the bitstream based on acoding method such as exponential Golomb coding, CAVLC, or CABAC, andoutput values of syntax elements required for image reconstruction andquantized values of transform coefficients for residual. Morespecifically, the CABAC entropy decoding method may receive a bincorresponding to each syntax element in the bitstream, determine acontext model using a decoding target syntax element information,decoding information of a neighboring block and a decoding target blockor information of a symbol/bin decoded in a previous stage, and performarithmetic decoding on the bin by predicting a probability of occurrenceof a bin according to the determined context model, and generate asymbol corresponding to the value of each syntax element. In this case,the CABAC entropy decoding method may update the context model by usingthe information of the decoded symbol/bin for a context model of a nextsymbol/bin after determining the context model. The information relatedto the prediction among the information decoded by the entropy decoder210 may be provided to the prediction unit (the inter prediction unit260 and the intra prediction unit 265), and the residual value on whichthe entropy decoding was performed in the entropy decoder 210, that is,the quantized transform coefficients and related parameter information,may be input to the dequantizer 220. In addition, information onfiltering among information decoded by the entropy decoder 210 may beprovided to the filter 240. Meanwhile, a receiver (not shown) forreceiving a signal output from the image encoding apparatus may befurther configured as an internal/external element of the image decodingapparatus 200, or the receiver may be a component of the entropy decoder210.

Meanwhile, the image decoding apparatus according to the presentdisclosure may be referred to as a video/image/picture decodingapparatus. The image decoding apparatus may be classified into aninformation decoder (video/image/picture information decoder) and asample decoder (video/image/picture sample decoder). The informationdecoder may include the entropy decoder 210. The sample decoder mayinclude at least one of the dequantizer 220, the inverse transformer230, the adder 235, the filter 240, the memory 250, the inter predictionunit 260 or the intra prediction unit 265.

The dequantizer 220 may dequantize the quantized transform coefficientsand output the transform coefficients. The dequantizer 220 may rearrangethe quantized transform coefficients in the form of a two-dimensionalblock. In this case, the rearrangement may be performed based on thecoefficient scanning order performed in the image encoding apparatus.The dequantizer 220 may perform dequantization on the quantizedtransform coefficients by using a quantization parameter (e.g.,quantization step size information) and obtain transform coefficients.

The inverse transformer 230 may inversely transform the transformcoefficients to obtain a residual signal (residual block, residualsample array).

The prediction unit may perform prediction on the current block andgenerate a predicted block including prediction samples for the currentblock. The prediction unit may determine whether intra prediction orinter prediction is applied to the current block based on theinformation on the prediction output from the entropy decoder 210 andmay determine a specific intra/inter prediction mode (predictiontechnique).

It is the same as described in the prediction unit of the image encodingapparatus 100 that the prediction unit may generate the predictionsignal based on various prediction methods (techniques) which will bedescribed later.

The intra prediction unit 265 may predict the current block by referringto the samples in the current picture. The description of the intraprediction unit 185 is equally applied to the intra prediction unit 265.

The inter prediction unit 260 may derive a predicted block for thecurrent block based on a reference block (reference sample array)specified by a motion vector on a reference picture. In this case, inorder to reduce the amount of motion information transmitted in theinter prediction mode, motion information may be predicted in units ofblocks, subblocks, or samples based on correlation of motion informationbetween the neighboring block and the current block. The motioninformation may include a motion vector and a reference picture index.The motion information may further include inter prediction direction(L0 prediction, L1 prediction, Bi-prediction, etc.) information. In thecase of inter prediction, the neighboring block may include a spatialneighboring block present in the current picture and a temporalneighboring block present in the reference picture. For example, theinter prediction unit 260 may configure a motion information candidatelist based on neighboring blocks and derive a motion vector of thecurrent block and/or a reference picture index based on the receivedcandidate selection information. Inter prediction may be performed basedon various prediction modes, and the information on the prediction mayinclude information indicating a mode of inter prediction for thecurrent block.

The adder 235 may generate a reconstructed signal (reconstructedpicture, reconstructed block, reconstructed sample array) by adding theobtained residual signal to the prediction signal (predicted block,predicted sample array) output from the prediction unit (including theinter prediction unit 260 and/or the intra prediction unit 265). Thedescription of the adder 155 is equally applicable to the adder 235.

Meanwhile, as described below, luma mapping with chroma scaling (LMCS)is applicable in a picture decoding process.

The filter 240 may improve subjective/objective image quality byapplying filtering to the reconstructed signal. For example, the filter240 may generate a modified reconstructed picture by applying variousfiltering methods to the reconstructed picture and store the modifiedreconstructed picture in the memory 250, specifically, a DPB of thememory 250. The various filtering methods may include, for example,deblocking filtering, a sample adaptive offset, an adaptive loop filter,a bilateral filter, and the like.

The (modified) reconstructed picture stored in the DPB of the memory 250may be used as a reference picture in the inter prediction unit 260. Thememory 250 may store the motion information of the block from which themotion information in the current picture is derived (or decoded) and/orthe motion information of the blocks in the picture that have alreadybeen reconstructed. The stored motion information may be transmitted tothe inter prediction unit 260 so as to be utilized as the motioninformation of the spatial neighboring block or the motion informationof the temporal neighboring block. The memory 250 may storereconstructed samples of reconstructed blocks in the current picture andtransfer the reconstructed samples to the intra prediction unit 265.

In the present disclosure, the embodiments described in the filter 160,the inter prediction unit 180, and the intra prediction unit 185 of theimage encoding apparatus 100 may be equally or correspondingly appliedto the filter 240, the inter prediction unit 260, and the intraprediction unit 265 of the image decoding apparatus 200.

Overview of Inter Prediction

An image encoding apparatus/image decoding apparatus may perform interprediction in units of blocks to derive a prediction sample. Interprediction may mean prediction derived in a manner that is dependent ondata elements of picture(s) other than a current picture. When interprediction applies to the current block, a predicted block for thecurrent block may be derived based on a reference block specified by amotion vector on a reference picture.

In this case, in order to reduce the amount of motion informationtransmitted in an inter prediction mode, motion information of thecurrent block may be derived based on correlation of motion informationbetween a neighboring block and the current block, and motioninformation may be derived in units of blocks, subblocks or samples. Themotion information may include a motion vector and a reference pictureindex. The motion information may further include inter prediction typeinformation. Here, the inter prediction type information may meandirectional information of inter prediction. The inter prediction typeinformation may indicate that a current block is predicted using one ofL0 prediction, L1 prediction or Bi-prediction.

When applying inter prediction to the current block, the neighboringblock of the current block may include a spatial neighboring blockpresent in the current picture and a temporal neighboring block presentin the reference picture. A reference picture including the referenceblock for the current block and a reference picture including thetemporal neighboring block may be the same or different. The temporalneighboring block may be referred to as a collocated reference block orcollocated CU (colCU), and the reference picture including the temporalneighboring block may be referred to as a collocated picture (colPic).

Meanwhile, a motion information candidate list may be constructed basedon the neighboring blocks of the current block, and, in this case, flagor index information indicating which candidate is used may be signaledin order to derive the motion vector of the current block and/or thereference picture index.

The motion information may include L0 motion information and/or L1motion information according to the inter prediction type. The motionvector in an L0 direction may be defined as an L0 motion vector or MVL0,and the motion vector in an L1 direction may be defined as an L1 motionvector or MVL1. Prediction based on the L0 motion vector may be definedas L0 prediction, prediction based on the L1 motion vector may bedefined as L1 prediction, and prediction based both the L0 motion vectorand the L1 motion vector may be defined as Bi-prediction. Here, the L0motion vector may mean a motion vector associated with a referencepicture list L0 and the L1 motion vector may mean a motion vectorassociated with a reference picture list L1.

The reference picture list L0 may include pictures before the currentpicture in output order as reference pictures, and the reference picturelist L1 may include pictures after the current picture in output order.The previous pictures may be defined as forward (reference) pictures andthe subsequent pictures may be defined as backward (reference) pictures.Meanwhile, the reference picture list L0 may further include picturesafter the current picture in output order as reference pictures. In thiscase, within the reference picture list L0, the previous pictures may befirst indexed and the subsequent pictures may then be indexed. Thereference picture list L1 may further include pictures before thecurrent picture in output order as reference pictures. In this case,within the reference picture list L1, the subsequent pictures may befirst indexed and the previous pictures may then be indexed. Here, theoutput order may correspond to picture order count (POC) order.

FIG. 4 is a flowchart illustrating an inter prediction based video/imageencoding method.

FIG. 5 is a view illustrating the configuration of an inter predictor180 according to the present disclosure.

The encoding method of FIG. 6 may be performed by the image encodingapparatus of FIG. 2 . Specifically, step S410 may be performed by theinter predictor 180, and step S420 may be performed by the residualprocessor. Specifically, step S420 may be performed by the subtractor115. Step S430 may be performed by the entropy encoder 190. Theprediction information of step S630 may be derived by the interpredictor 180, and the residual information of step S630 may be derivedby the residual processor. The residual information is information onthe residual samples. The residual information may include informationon quantized transform coefficients for the residual samples. Asdescribed above, the residual samples may be derived as transformcoefficients through the transformer 120 of the image encodingapparatus, and the transform coefficient may be derived as quantizedtransform coefficients through the quantizer 130. Information on thequantized transform coefficients may be encoded by the entropy encoder190 through a residual coding procedure.

The image encoding apparatus may perform inter prediction with respectto a current block (S410). The image encoding apparatus may derive aninter prediction mode and motion information of the current block andgenerate prediction samples of the current block. Here, inter predictionmode determination, motion information derivation and prediction samplesgeneration procedures may be simultaneously performed or any one thereofmay be performed before the other procedures. For example, as shown inFIG. 5 , the inter prediction unit 180 of the image encoding apparatusmay include a prediction mode determination unit 181, a motioninformation derivation unit 182 and a prediction sample derivation unit183. The prediction mode determination unit 181 may determine theprediction mode of the current block, the motion information derivationunit 182 may derive the motion information of the current block, and theprediction sample derivation unit 183 may derive the prediction samplesof the current block. For example, the inter prediction unit 180 of theimage encoding apparatus may search for a block similar to the currentblock within a predetermined area (search area) of reference picturesthrough motion estimation, and derive a reference block whose differencefrom the current block is equal to or less than a predeterminedcriterion or a minimum. Based on this, a reference picture indexindicating a reference picture in which the reference block is locatedmay be derived, and a motion vector may be derived based on a positiondifference between the reference block and the current block. The imageencoding apparatus may determine a mode applying to the current blockamong various inter prediction modes. The image encoding apparatus maycompare rate-distortion (RD) costs for the various prediction modes anddetermine an optimal inter prediction mode of the current block.However, the method of determining the inter prediction mode of thecurrent block by the image encoding apparatus is not limited to theabove example, and various methods may be used.

For example, the inter prediction mode of the current block may bedetermined to be at least one of a merge mode, a merge skip mode, amotion vector prediction (MVP) mode, a symmetric motion vectordifference (SMVD) mode, an affine mode, a subblock-based merge mode, anadaptive motion vector resolution (AMVR) mode, a history-based motionvector predictor (HMVP) mode, a pair-wise average merge mode, a mergemode with motion vector differences (MMVD) mode, a decoder side motionvector refinement (DMVR) mode, a combined inter and intra prediction(CIIP) mode or a geometric partitioning mode (GPM).

For example, when a skip mode or a merge mode applies to the currentblock, the image encoding apparatus may derive merge candidates fromneighboring blocks of the current block and construct a merge candidatelist using the derived merge candidates. In addition, the image encodingapparatus may derive a reference block whose difference from the currentblock is equal to or less than a predetermined criterion or a minimum,among reference blocks indicated by merge candidates included in themerge candidate list. In this case, a merge candidate associated withthe derived reference block may be selected, and merge index informationindicating the selected merge candidate may be generated and signaled toan image decoding apparatus. The motion information of the current blockmay be derived using the motion information of the selected mergecandidate.

As another example, when an MVP mode applies to the current block, theimage encoding apparatus may derive motion vector predictor (MVP)candidates from the neighboring blocks of the current block andconstruct an MVP candidate list using the derived MVP candidates. Inaddition, the image encoding apparatus may use the motion vector of theMVP candidate selected from among the MVP candidates included in the MVPcandidate list as the MVP of the current block. In this case, forexample, the motion vector indicating the reference block derived by theabove-described motion estimation may be used as the motion vector ofthe current block, an MVP candidate with a motion vector having asmallest difference from the motion vector of the current block amongthe MVP candidates may be the selected MVP candidate. A motion vectordifference (MVD) which is a difference obtained by subtracting the MVPfrom the motion vector of the current block may be derived. In thiscase, index information indicating the selected MVP candidate andinformation on the MVD may be signaled to the image decoding apparatus.In addition, when applying the MVP mode, the value of the referencepicture index may be constructed as reference picture index informationand separately signaled to the image decoding apparatus.

The image encoding apparatus may derive residual samples based on theprediction samples (S420). The image encoding apparatus may derive theresidual samples through comparison between original samples of thecurrent block and the prediction samples. For example, the residualsample may be derived by subtracting a corresponding prediction samplefrom an original sample.

The image encoding apparatus may encode image information includingprediction information and residual information (S430). The imageencoding apparatus may output the encoded image information in the formof a bitstream. The prediction information may include prediction modeinformation (e.g., skip flag, merge flag or mode index, etc.) andinformation on motion information as information related to theprediction procedure. Among the prediction mode information, the skipflag indicates whether a skip mode applies to the current block, and themerge flag indicates whether the merge mode applies to the currentblock. Alternatively, the prediction mode information may indicate oneof a plurality of prediction modes, such as a mode index. When the skipflag and the merge flag are 0, it may be determined that the MVP modeapplies to the current block. The information on the motion informationmay include candidate selection information (e.g., merge index, mvp flagor mvp index) which is information for deriving a motion vector. Amongthe candidate selection information, the merge index may be signaledwhen the merge mode applies to the current block and may be informationfor selecting one of merge candidates included in a merge candidatelist. Among the candidate selection information, the MVP flag or the MVPindex may be signaled when the MVP mode applies to the current block andmay be information for selecting one of MVP candidates in an MVPcandidate list. Specifically, the MVP flag may be signaled using asyntax element mvp_l0_flag or mvp_l1_flag. In addition, the informationon the motion information may include information on the above-describedMVD and/or reference picture index information. In addition, theinformation on the motion information may include information indicatingwhether to apply L0 prediction, L1 prediction or Bi-prediction. Theresidual information is information on the residual samples. Theresidual information may include information on quantized transformcoefficients for the residual samples.

The output bitstream may be stored in a (digital) storage medium andtransmitted to the image decoding apparatus or may be transmitted to theimage decoding apparatus via a network.

As described above, the image encoding apparatus may generate areconstructed picture (a picture including reconstructed samples and areconstructed block) based on the reference samples and the residualsamples. This is for the image encoding apparatus to derive the sameprediction result as that performed by the image decoding apparatus,thereby increasing coding efficiency. Accordingly, the image encodingapparatus may store the reconstructed picture (or the reconstructedsamples and the reconstructed block) in a memory and use the same as areference picture for inter prediction. As described above, an in-loopfiltering procedure is further applicable to the reconstructed picture.

FIG. 6 is a flowchart illustrating an inter prediction based video/imagedecoding method.

FIG. 7 is a view illustrating the configuration of an inter predictionunit 260 according to the present disclosure.

The image decoding apparatus may perform operation corresponding tooperation performed by the image encoding apparatus. The image decodingapparatus may perform prediction with respect to a current block basedon received prediction information and derive prediction samples.

The decoding method of FIG. 6 may be performed by the image decodingapparatus of FIG. 3 . Steps S610 to S630 may be performed by the interprediction unit 260, and the prediction information of step S610 and theresidual information of step S640 may be obtained from a bitstream bythe entropy decoder 210. The residual processor of the image decodingapparatus may derive residual samples for a current block based on theresidual information (S640). Specifically, the dequantizer 220 of theresidual processor may perform dequantization based on quantizedtransform coefficients derived based on the residual information toderive transform coefficients, and the inverse transformer 230 of theresidual processor may perform inverse transform with respect to thetransform coefficients to derive the residual samples for the currentblock. Step S650 may be performed by the adder 235 or the reconstructor.

Specifically, the image decoding apparatus may determine the predictionmode of the current block based on the received prediction information(S610). The image decoding apparatus may determine which interprediction mode applies to the current block based on the predictionmode information in the prediction information.

For example, it may be determined whether the skip mode applies to thecurrent block based on the skip flag. In addition, it may be determinedwhether the merge mode or the MVP mode applies to the current blockbased on the merge flag. Alternatively, one of various inter predictionmode candidates may be selected based on the mode index. The interprediction mode candidates may include a skip mode, a merge mode and/oran MVP mode or may include various inter prediction modes which will bedescribed below.

The image decoding apparatus may derive the motion information of thecurrent block based on the determined inter prediction mode (S620). Forexample, when the skip mode or the merge mode applies to the currentblock, the image decoding apparatus may construct a merge candidatelist, which will be described below, and select one of merge candidatesincluded in the merge candidate list. The selection may be performedbased on the above-described candidate selection information (mergeindex). The motion information of the current block may be derived usingthe motion information of the selected merge candidate. For example, themotion information of the selected merge candidate may be used as themotion information of the current block.

As another example, when the MVP mode applies to the current block, theimage decoding apparatus may construct an MVP candidate list and use themotion vector of an MVP candidate selected from among MVP candidatesincluded in the MVP candidate list as an MVP of the current block. Theselection may be performed based on the above-described candidateselection information (mvp flag or mvp index). In this case, the MVD ofthe current block may be derived based on information on the MVD, andthe motion vector of the current block may be derived based on MVP andMVD of the current block. In addition, the reference picture index ofthe current block may be derived based on the reference picture indexinformation. A picture indicated by the reference picture index in thereference picture list of the current block may be derived as areference picture referenced for inter prediction of the current block.

The image decoding apparatus may generate prediction samples of thecurrent block based on motion information of the current block (S630).In this case, the reference picture may be derived based on thereference picture index of the current block, and the prediction samplesof the current block may be derived using the samples of the referenceblock indicated by the motion vector of the current block on thereference picture. In some cases, a prediction sample filteringprocedure may be further performed with respect to all or some of theprediction samples of the current block.

For example, as shown in FIG. 7 , the inter prediction unit 260 of theimage decoding apparatus may include a prediction mode determinationunit 261, a motion information derivation unit 262 and a predictionsample derivation unit 263. In the inter prediction unit 260 of theimage decoding apparatus, the prediction mode determination unit 261 maydetermine the prediction mode of the current block based on the receivedprediction mode information, the motion information derivation unit 262may derive the motion information (a motion vector and/or a referencepicture index, etc.) of the current block based on the received motioninformation, and the prediction sample derivation unit 263 may derivethe prediction samples of the current block.

The image decoding apparatus may generate residual samples of thecurrent block based the received residual information (S640). The imagedecoding apparatus may generate the reconstructed samples of the currentblock based on the prediction samples and the residual samples andgenerate a reconstructed picture based on this (S650). Thereafter, anin-loop filtering procedure is applicable to the reconstructed pictureas described above.

As described above, the inter prediction procedure may include step ofdetermining an inter prediction mode, step of deriving motioninformation according to the determined prediction mode, and step ofperforming prediction (generating prediction samples) based on thederived motion information. The inter prediction procedure may beperformed by the image encoding apparatus and the image decodingapparatus, as described above.

Hereinafter, the step of deriving the motion information according tothe prediction mode will be described in greater detail.

As described above, inter prediction may be performed using motioninformation of a current block. An image encoding apparatus may deriveoptimal motion information of a current block through a motionestimation procedure. For example, the image encoding apparatus maysearch for a similar reference block with high correlation within apredetermined search range in the reference picture using an originalblock in an original picture for the current block in fractional pixelunit, and derive motion information using the same. Similarity of theblock may be calculated based on a sum of absolute differences (SAD)between the current block and the reference block. In this case, motioninformation may be derived based on a reference block with a smallestSAD in the search area. The derived motion information may be signaledto an image decoding apparatus according to various methods based on aninter prediction mode.

When a merge mode applies to a current block, motion information of thecurrent block is not directly transmitted and motion information of thecurrent block is derived using motion information of a neighboringblock. Accordingly, motion information of a current prediction block maybe indicated by transmitting flag information indicating that the mergemode is used and candidate selection information (e.g., a merge index)indicating which neighboring block is used as a merge candidate. In thepresent disclosure, since the current block is a unit of predictionperformance, the current block may be used as the same meaning as thecurrent prediction block, and the neighboring block may be used as thesame meaning as a neighboring prediction block.

The image encoding apparatus may search for merge candidate blocks usedto derive the motion information of the current block to perform themerge mode. For example, up to five merge candidate blocks may be used,without being limited thereto. The maximum number of merge candidateblocks may be transmitted in a slice header or a tile group header,without being limited thereto. After finding the merge candidate blocks,the image encoding apparatus may generate a merge candidate list andselect a merge candidate block with smallest RD cost as a final mergecandidate block.

The present disclosure provides various embodiments for the mergecandidate blocks configuring the merge candidate list. The mergecandidate list may use, for example, five merge candidate blocks. Forexample, four spatial merge candidates and one temporal merge candidatemay be used.

FIG. 8 is a view illustrating neighboring blocks available as a spatialmerge candidate.

FIG. 9 is a view schematically illustrating a merge candidate listconstruction method according to an example of the present disclosure.

An image encoding/decoding apparatus may insert, into a merge candidatelist, spatial merge candidates derived by searching for spatialneighboring blocks of a current block (S910). For example, as shown inFIG. 8 , the spatial neighboring blocks may include a bottom-left cornerneighboring block A₀, a left neighboring block A₁, a top-right cornerneighboring block B₀, a top neighboring block B₁, and a top-left cornerneighboring block B₂ of the current block. However, this is an exampleand, in addition to the above-described spatial neighboring blocks,additional neighboring blocks such as a right neighboring block, abottom neighboring block and a bottom-right neighboring block may befurther used as the spatial neighboring blocks. The imageencoding/decoding apparatus may detect available blocks by searching forthe spatial neighboring blocks based on priority and derive motioninformation of the detected blocks as the spatial merge candidates. Forexample, the image encoding/decoding apparatus may construct a mergecandidate list by searching for the five blocks shown in FIG. 8 in orderof A₁, B₁, B₀, A₀ and B₂ and sequentially indexing available candidates.

The image encoding/decoding apparatus may insert, into the mergecandidate list, a temporal merge candidate derived by searching fortemporal neighboring blocks of the current block (S920). The temporalneighboring blocks may be located on a reference picture which isdifferent from a current picture in which the current block is located.A reference picture in which the temporal neighboring block is locatedmay be referred to as a collocated picture or a col picture. Thetemporal neighboring block may be searched for in order of abottom-right corner neighboring block and a bottom-right center block ofthe co-located block for the current block on the col picture.Meanwhile, when applying motion data compression in order to reducememory load, specific motion information may be stored as representativemotion information for each predetermined storage unit for the colpicture. In this case, motion information of all blocks in thepredetermined storage unit does not need to be stored, thereby obtainingmotion data compression effect. In this case, the predetermined storageunit may be predetermined as, for example, 16×16 sample unit or 8×8sample unit or size information of the predetermined storage unit may besignaled from the image encoding apparatus to the image decodingapparatus. When applying the motion data compression, the motioninformation of the temporal neighboring block may be replaced with therepresentative motion information of the predetermined storage unit inwhich the temporal neighboring block is located. That is, in this case,from the viewpoint of implementation, the temporal merge candidate maybe derived based on the motion information of a prediction blockcovering an arithmetic left-shifted position after an arithmetic rightshift by a predetermined value based on coordinates (top-left sampleposition) of the temporal neighboring block, not a prediction blocklocated on the coordinates of the temporal neighboring block. Forexample, when the predetermined storage unit is a 2^(n)×2^(n) sampleunit and the coordinates of the temporal neighboring block are (xTnb,yTnb), the motion information of a prediction block located at amodified position ((xTnb>>n)<<n), (yTnb>>n)<<n)) may be used for thetemporal merge candidate. Specifically, for example, when thepredetermined storage unit is a 16×16 sample unit and the coordinates ofthe temporal neighboring block are (xTnb, yTnb), the motion informationof a prediction block located at a modified position ((xTnb>>4)<<4),(yTnb>>4)<<4)) may be used for the temporal merge candidate.Alternatively, for example, when the predetermined storage unit is an8×8 sample unit and the coordinates of the temporal neighboring blockare (xTnb, yTnb), the motion information of a prediction block locatedat a modified position ((xTnb>>3)<<3), (yTnb>>3)<<3)) may be used forthe temporal merge candidate.

Referring to FIG. 9 again, the image encoding/decoding apparatus maycheck whether the current number of merge candidates is less than amaximum number of merge candidates (S930). The maximum number of mergecandidates may be predefined or signaled from the image encodingapparatus to the image decoding apparatus. For example, the imageencoding apparatus may generate and encode information on the maximumnumber of merge candidates and transmit the encoded information to theimage decoding apparatus in the form of a bitstream. When the maximumnumber of merge candidates is satisfied, a subsequent candidate additionprocess S940 may not be performed.

When the current number of merge candidates is less than the maximumnumber of merge candidates as a checked result of step S930, the imageencoding/decoding apparatus may derive an additional merge candidateaccording to a predetermined method and then insert the additional mergecandidate to the merge candidate list (S940). The additional mergecandidate may include, for example, at least one of history based mergecandidate(s), pair-wise average merge candidate(s), ATMVP, combinedbi-predictive merge candidate(s) (when a slice/tile group type of acurrent slice/tile group is a B type) and/or zero vector mergecandidate(s).

When the current number of merge candidates is not less than the maximumnumber of merge candidates as a checked result of step S930, the imageencoding/decoding apparatus may end the construction of the mergecandidate list. In this case, the image encoding apparatus may select anoptimal merge candidate from among the merge candidates configuring themerge candidate list, and signal candidate selection information (e.g.,merge candidate index or merge index) indicating the selected mergecandidate to the image decoding apparatus. The image decoding apparatusmay select the optimal merge candidate based on the merge candidate listand the candidate selection information.

The motion information of the selected merge candidate may be used asthe motion information of the current block, and the prediction samplesof the current block may be derived based on the motion information ofthe current block, as described above. The image encoding apparatus mayderive the residual samples of the current block based on the predictionsamples and signal residual information of the residual samples to theimage decoding apparatus. The image decoding apparatus may generatereconstructed samples based on the residual samples derived based on theresidual information and the prediction samples and generate thereconstructed picture based on the same, as described above.

When applying a skip mode to the current block, the motion informationof the current block may be derived using the same method as the case ofapplying the merge mode. However, when applying the skip mode, aresidual signal for a corresponding block is omitted and thus theprediction samples may be directly used as the reconstructed samples.The above skip mode may apply, for example, when the value of cu skipflag is 1.

Hereinafter, a method of deriving a spatial candidate in a merge modeand/or a skip mode will be described. The spatial candidate mayrepresent the above-described spatial merge candidate.

Derivation of the spatial candidate may be performed based on spatiallyneighboring blocks. For example, a maximum of four spatial candidatesmay be derived from candidate blocks existing at positions shown in FIG.8 . The order of deriving spatial candidates may be A1->B1->B0->A0->B2.However, the order of deriving spatial candidates is not limited to theabove order and may be, for example, B1->A1->B0->A0->B2. The lastposition in the order (position B2 in the above example) may beconsidered when at least one of the preceding four positions (A1, B1, B0and A0 in the above example) is not available. In this case, a block ata predetermined position being not available may include a correspondingblock belonging to a slice or tile different from the current block or acorresponding block being an intra-predicted block. When a spatialcandidate is derived from a first position in the order (A1 or B1 in theabove example), redundancy check may be performed on spatial candidatesof subsequent positions. For example, when motion information of asubsequent spatial candidate is the same as motion information of aspatial candidate already included in a merge candidate list, thesubsequent spatial candidate may not be included in the merge candidatelist, thereby improving encoding efficiency. Redundancy check performedon the subsequent spatial candidate may be performed on some candidatepairs instead of all possible candidate pairs, thereby reducingcomputational complexity.

FIG. 10 is a view illustrating a candidate pair for redundancy checkperformed on a spatial candidate.

In the example shown in FIG. 10 , redundancy check for a spatialcandidate at a position B₀ may be performed only for a spatial candidateat a position A₀. In addition, redundancy check for a spatial candidateat a position B₁ may be performed only for a spatial candidate at aposition B₀. In addition, redundancy check for a spatial candidate at aposition A₁ may be performed only for a spatial candidate at a positionA₀. Finally, redundancy check for a spatial candidate at a position B₂may be performed only for spatial candidates at a position A₀ and aposition B₀.

In the example shown in FIG. 10 , the order of deriving the spatialcandidates is A0->B0->B1->A1->B2. However, the present disclosure is notlimited thereto and, even if the order of deriving the spatialcandidates is changed, as in the example shown in FIG. 10 , redundancycheck may be performed only on some candidate pairs.

Hereinafter, a method of deriving a temporal candidate in the case of amerge mode and/or a skip mode will be described. The temporal candidatemay represent the above-described temporal merge candidate. In addition,the motion vector of the temporal candidate may correspond to thetemporal candidate of an MVP mode.

In the case of the temporal candidate, only one candidate may beincluded in a merge candidate list. In the process of deriving thetemporal candidate, the motion vector of the temporal candidate may bescaled. For example, the scaling may be performed based on a collocatedblock (CU) (hereinafter referred to as a “col block”) belonging to acollocated reference picture (colPic) (hereinafter referred to as “colpicture”). A reference picture list used to derive the col block may beexplicitly signaled in a slice header.

FIG. 11 is a view illustrating a method of scaling a motion vector of atemporal candidate.

In FIG. 11 , curr_CU and curr_pic respectively denote a current blockand a current picture, and col_CU and col_pic respectively denote a colblock and a col picture. In addition, curr_ref denote a referencepicture of a current block, and col_ref denotes a reference picture of acol block. In addition, tb denotes a distance between the referencepicture of the current block and the current picture, and td denotes adistance between the reference picture of the col block and the colpicture. tb and td may denote values corresponding to differences in POC(Picture Order Count) between pictures. Scaling of the motion vector ofthe temporal candidate may be performed based on tb and td. In addition,the reference picture index of the temporal candidate may be set to 0.

FIG. 12 is a view illustrating a position where a temporal candidate isderived.

In FIG. 12 , a block with a thick solid line denotes a current block. Atemporal candidate may be derived from a block in a col picturecorresponding to a position C₀ (bottom-right position) or C₁ (centerposition) of FIG. 12 . First, it may be determined whether the positionC₀ is available and, when the position C₀ is available, the temporalcandidate may be derived based on the position C₀. When the position C₀is not available, the temporal candidate may be derived based on theposition C₁. For example, when a block in the col picture at theposition C₀ is an intra-predicted block or is located outside a currentCTU row, it may be determined that the position C₀ is not available.

As described above, when applying motion data compression, the motionvector of the col block may be stored for each predetermined unit block.In this case, in order to derive the motion vector of a block coveringthe position C₀ or the position C₁, the position C₀ or the position C₁may be modified. For example, when the predetermined unit block is an8×8 block and the position C₀ or the position C₁ is (xColCi, yColCi), aposition for deriving the temporal candidate may be modified to((xColCi>>3)<<3, (yColCi>>3)<<3).

Hereinafter, a method of deriving a history-based candidate in the caseof a merge mode and/or a skip mode will be described. The history-basedcandidate may be expressed by a history-based merge candidate.

The history-based candidate may be added to a merge candidate list aftera spatial candidate and a temporal candidate are added to the mergecandidate list. For example, motion information of a previouslyencoded/decoded block may be stored at a table and used as ahistory-based candidate of a current block. The table may store aplurality of history-based candidates during the encoding/decodingprocess. The table may be initialized when a new CTU row starts.Initializing the table may mean that the corresponding table is emptiedby deleting all the history-based candidates stored in the table.Whenever there is an inter-predicted block, related motion informationmay be added to the table as a last entry. In this case, theinter-predicted block may not be a block predicted based on a subblock.The motion information added to the table may be used as a newhistory-based candidate.

The table of the history-based candidates may have a predetermined size.For example, the size may be 5. In this case, the table may store amaximum of five history-based candidates. When a new candidate is addedto the table, a limited first-in-first-out (FIFO) rule in whichredundancy check of checking whether the same candidate is present inthe table may apply. If the same candidate is already present in thetable, the same candidate may be deleted from the table and positions ofall subsequent history-based candidates may be moved forward.

The history-based candidate may be used in a process of configuring themerge candidate list. In this case, the history-based candidatesrecently included in the table may be sequentially checked and locatedat a position after the temporal candidate of the merge candidate list.When the history-based candidate is included in the merge candidatelist, redundancy check with the spatial candidates or temporalcandidates already included in the merge candidate list may beperformed. If the spatial candidate or temporal candidate alreadyincluded in the merge candidate list and the history-based candidateoverlap, the history-based candidate may not be included in the mergecandidate list. By simplifying the redundancy check as follows, theamount of computation may be reduced.

The number of history-based candidates used to generate the mergecandidate list may be set to (N<=4) ? M: (8−N). In this case, N maydenote the number of candidates already included in the merge candidatelist, and M may denote the number of available history-based candidateincluded in the table. That is, when 4 or less candidates are includedin the merge candidate list, the number of history-based candidates usedto generate the merge candidate list may be M, and, when N candidatesgreater than 4 are included in the merge candidate list, the number ofhistory-based candidates used to generate the merge candidate list maybe set to (8−N).

When the total number of available merge candidates reaches (maximumallowable number of merge candidates−1), configuration of the mergecandidate list using the history-based candidate may end.

Hereinafter, a method of deriving a pair-wise average candidate in thecase of a merge mode and/or a skip mode will be described. The pair-wiseaverage candidate may be represented by a pair-wise average mergecandidate or a pair-wise candidate.

The pair-wise average candidate may be generated by obtaining predefinedcandidate pairs from the candidates included in the merge candidate listand averaging them. The predefined candidate pairs may be {(0, 1), (0,2), (1, 2), (0, 3), (1, 3), (2, 3)} and the number configuring eachcandidate pair may be an index of the merge candidate list. That is, thepredefined candidate pair (0, 1) may mean a pair of index 0 candidateand index 1 candidate of the merge candidate list, and the pair-wiseaverage candidate may be generated by an average of index 0 candidateand index 1 candidate. Derivation of pair-wise average candidates may beperformed in the order of the predefined candidate pairs. That is, afterderiving a pair-wise average candidate for the candidate pair (0, 1),the process of deriving the pair-wise average candidate may be performedin order of the candidate pair (0, 2) and the candidate pair (1, 2). Thepair-wise average candidate derivation process may be performed untilconfiguration of the merge candidate list is completed. For example, thepair-wise average candidate derivation process may be performed untilthe number of merge candidates included in the merge candidate listreaches a maximum merge candidate number.

The pair-wise average candidate may be calculated separately for eachreference picture list. When two motion vectors are available for onereference picture list (L0 list or L1 list), an average of the twomotion vectors may be computed. In this case, even if the two motionvectors indicate different reference pictures, an average of the twomotion vectors may be performed. If only one motion vector is availablefor one reference picture list, an available motion vector may be usedas a motion vector of a pair-wise average candidate. If both the twomotion vectors are not available for one reference picture list, it maybe determined that the reference picture list is not valid.

When configuration of the merge candidate list is not completed evenafter the pair-wise average candidate is included in the merge candidatelist, a zero vector may be added to the merge candidate list until themaximum merge candidate number is reached.

When applying an MVP mode to the current block, a motion vectorpredictor (mvp) candidate list may be generated using a motion vector ofa reconstructed spatial neighboring block (e.g., the neighboring blockshown in FIG. 8 ) and/or a motion vector corresponding to the temporalneighboring block (or Col block). That is, the motion vector of thereconstructed spatial neighboring blocks and the motion vectorcorresponding to the temporal neighboring blocks may be used as motionvector predictor candidates of the current block. When applyingbi-prediction, an mvp candidate list for L0 motion informationderivation and an mvp candidate list for L1 motion informationderivation are individually generated and used. Prediction information(or information on prediction) of the current block may includecandidate selection information (e.g., an MVP flag or an MVP index)indicating an optimal motion vector predictor candidate selected fromamong the motion vector predictor candidates included in the mvpcandidate list. In this case, a prediction unit may select a motionvector predictor of a current block from among the motion vectorpredictor candidates included in the mvp candidate list using thecandidate selection information. The prediction unit of the imageencoding apparatus may obtain and encode a motion vector difference(MVD) between the motion vector of the current block and the motionvector predictor and output the encoded MVD in the form of a bitstream.That is, the MVD may be obtained by subtracting the motion vectorpredictor from the motion vector of the current block. The predictionunit of the image decoding apparatus may obtain a motion vectordifference included in the information on prediction and derive themotion vector of the current block through addition of the motion vectordifference and the motion vector predictor. The prediction unit of theimage decoding apparatus may obtain or derive a reference picture indexindicating a reference picture from the information on prediction.

FIG. 13 is a view schematically illustrating a motion vector predictorcandidate list construction method according to an example of thepresent disclosure.

First, a spatial candidate block of a current block may be searched forand available candidate blocks may be inserted into an MVP candidatelist (S1010). Thereafter, it is determined whether the number of MVPcandidates included in the MVP candidate list is less than 2 (S1020)and, when the number of MVP candidates is two, construction of the MVPcandidate list may be completed.

In step S1020, when the number of available spatial candidate blocks isless than 2, a temporal candidate block of the current block may besearched for and available candidate blocks may be inserted into the MVPcandidate list (S1030). When the temporal candidate blocks are notavailable, a zero motion vector may be inserted into the MVP candidatelist (S1040), thereby completing construction of the MVP candidate list.

Meanwhile, when applying an mvp mode, a reference picture index may beexplicitly signaled. In this case, a reference picture index refidxL0for L0 prediction and a reference picture index refidxL1 for L1prediction may be distinguishably signaled. For example, when applyingthe MVP mode and applying Bi-prediction, both information on refidxL0and information on refidxL1 may be signaled.

As described above, when applying the MVP mode, information on MVPderived by the image encoding apparatus may be signaled to the imagedecoding apparatus. Information on the MVD may include, for example, anMVD absolute value and information indicating x and y components for asign. In this case, when the MVD absolute value is greater than 0,whether the MVD absolute value is greater than 1 and informationindicating an MVD remainder may be signaled stepwise. For example,information indicating whether the MVD absolute value is greater than 1may be signaled only when a value of flag information indicating whetherthe MVD absolute value is greater than 0 is 1.

Overview of Affine Mode

Hereinafter, an affine mode which is an example of an inter predictionmode will be described in detail. In a conventional videoencoding/decoding system, only one motion vector is used to expressmotion information of a current block. However, in this method, there isa problem in that optimal motion information is only expressed in unitsof blocks, but optimal motion information cannot be expressed in unitsof pixels. In order to solve this problem, an affine mode definingmotion information of a block in units of pixels has been proposed.According to the affine mode, a motion vector for each pixel and/orsubblock unit of a block may be determined using two to four motionvectors associated with a current block.

Compared to the existing motion information expressed using translationmotion (or displacement) of a pixel value, in the affine mode, motioninformation for each pixel may be expressed using at least one oftranslation motion, scaling, rotation or shear. Among them, an affinemode in which motion information for each pixel is expressed usingdisplacement, scaling or rotation may be similarity or simplified affinemode. The affine mode in the following description may mean a similarityor simplified affine mode.

Motion information in the affine mode may be expressed using two or morecontrol point motion vectors (CPMVs). A motion vector of a specificpixel position of a current block may be derived using a CPMV. In thiscase, a set of motion vectors for each pixel and/or subblock of acurrent block may be defined as an affine motion vector field (affineMVF).

FIG. 14 is a view illustrating a parameter model of an affine mode.

When an affine mode applies to a current block, an affine MVF may bederived using one of a 4-parameter model and a 6-parameter model. Inthis case, the 4-parameter model may mean a model type in which twoCPMVs are used and the 6-parameter model may mean a model type in whichthree CPMVs are used. FIGS. 14(a) and 14(b) show CPMVs used in the4-parameter model and the 6-parameter model, respectively.

When the position of the current block is (x, y), a motion vectoraccording to the pixel position may be derived according to Equation 1or 2 below. For example, the motion vector according to the 4-parametermodel may be derived according to Equation 1 and the motion vectoraccording to the 6-parameter model may be derived according to Equation2.

$\begin{matrix}\{ \begin{matrix}{{mv}_{x} = {{\frac{{mv}_{1x} - {mv}_{0x}}{W}x} + {\frac{{mv}_{1y} - {mv}_{0y}}{W}y} + {mv}_{0x}}} \\{{mv}_{y} = {{\frac{{mv}_{1y} - {mv}_{0y}}{W}x} + {\frac{{mv}_{1x} - {mv}_{0x}}{W}y} + {mv}_{0y}}}\end{matrix}  & \lbrack {{Equation}1} \rbrack\end{matrix}$ $\begin{matrix}\{ \begin{matrix}{{mv}_{x} = {{\frac{{mv}_{1x} - {mv}_{0x}}{W}x} + {\frac{{mv}_{1y} - {mv}_{0y}}{W}y} + {mv}_{0x}}} \\{{mv}_{y} = {{\frac{{mv}_{1y} - {mv}_{0y}}{W}x} + {\frac{{mv}_{1x} - {mv}_{0x}}{W}y} + {mv}_{0y}}}\end{matrix}  & \lbrack {{Equation}2} \rbrack\end{matrix}$

In Equations 1 and 2, mv0={mv_0x, mv_0y} may be a CPMV at the top leftcorner position of the current block, v1={mv_1x, mv_1y} may be a CPMV atthe top right position of the current block, and mv2={mv_2x, mv_2y} maybe a CPMV at the bottom left position of the current block. In thiscase, W and H respectively correspond to the width and height of thecurrent block, and mv={mv_x, mv_y} may mean a motion vector of a pixelposition {x, y}.

In an encoding/decoding process, an affine MVF may be determined inunits of pixels and/or predefined subblocks. When the affine MVF isdetermined in units of pixels, a motion vector may be derived based oneach pixel value. Meanwhile, when the affine MVF is determined in unitsof subblocks, a motion vector of a corresponding block may be derivedbased on a center pixel value of a subblock. The center pixel value maymean a virtual pixel present in the center of a subblock or a bottomright pixel among four pixels present in the center. In addition, thecenter pixel value may be a specific pixel in a subblock and may be apixel representing the subblock. In the present disclosure, the casewhere the affine MVF is determined in units of 4×4 subblocks will bedescribed. However, this is only for convenience of description and thesize of the subblock may be variously changed.

That is, when affine prediction is available, a motion model applicableto a current block may include three models, that is, a translationalmotion model, a 4-parameter affine motion model and 6-parameter affinemotion model. Here, the translational motion model may represent a modelused by an existing block unit motion vector, the 4-parameter affinemotion model may represent a model used by two CPMVs, and the6-parameter affine motion model may represent a model used by threeCPMVs. The affine mode may be divided into detailed modes according to amethod of encoding/decoding motion information. For example, the affinemode may be subdivided into an affine MVP mode and an affine merge mode.

When an affine merge mode applies for a current block, a CPMV may bederived from neighboring blocks of the current block encoded/decoded inthe affine mode. When at least one of the neighboring blocks of thecurrent block is encoded/decoded in the affine mode, the affine mergemode may apply for the current block. That is, when the affine mergemode applies for the current block, CPMVs of the current block may bederived using CPMVs of the neighboring blocks. For example, the CPMVs ofthe neighboring blocks may be determined to be the CPMVs of the currentblock or the CPMV of the current block may be derived based on the CPMVsof the neighboring blocks. When the CPMV of the current block is derivedbased on the CPMVs of the neighboring blocks, at least one of codingparameters of the current block or the neighboring blocks may be used.For example, CPMVs of the neighboring blocks may be modified based onthe size of the neighboring blocks and the size of the current block andused as the CPMVs of the current block.

Meanwhile, affine merge in which an MV is derived in units of subblocksmay be referred to as a subblock merge mode, which may be specified bymerge subblock flag having a first value (e.g., 1). In this case, anaffine merging candidate list described below may be referred to as asubblock merging candidate list. In this case, a candidate derived asSbTMVP described below may be further included in the subblock mergingcandidate list. In this case, the candidate derived as sbTMVP may beused as a candidate of index #0 of the subblock merging candidate list.In other words, the candidate derived as sbTMVP may be located in frontof an inherited affine candidates and constructed affine candidatesdescribed below in the subblock merging candidate list.

For example, an affine mode flag specifying whether an affine mode isapplicable to a current block may be defined, which may be signaled atleast one of higher levels of the current block, such as a sequence, apicture, a slice, a tile, a tile group, a brick, etc. For example, theaffine mode flag may be named sps_affine_enabled_flag.

When the affine merge mode applies, an affine merge candidate list maybe configured to derive the CPMV of the current block. In this case, theaffine merge candidate list may include at least one of an inheritedaffine merge candidate, a constructed affine merge candidate or a zeromerge candidate. The inherited affine merge candidate may mean acandidate derived using the CPMVs of the neighboring blocks when theneighboring blocks of the current block are encoded/decoded in theaffine mode. The constructed affine merge candidate may mean a candidatehaving each CPMV derived based on motion vectors of neighboring blocksof each control point (CP). Meanwhile, the zero merge candidate may meana candidate composed of CPMVs having a size of 0. In the followingdescription, the CP may mean a specific position of a block used toderive a CPMV. For example, the CP may be each vertex position of ablock.

FIG. 15 is a view illustrating a method of generating an affine mergecandidate list.

Referring to the flowchart of FIG. 15 , affine merge candidates may beadded to the affine merge candidate list in order of an inherited affinemerge candidate (S1210), a constructed affine merge candidate (S1220)and a zero merge candidate (S1230). The zero merge candidate may beadded when the number of candidates included in the candidate list doesnot satisfy a maximum number of candidates even though all the inheritedaffine merge candidates and the constructed affine merge candidates areadded to the affine merge candidate list. In this case, the zero mergecandidate may be added until the number of candidates of the affinemerge candidate list satisfies the maximum number of candidates.

FIG. 16 is a view illustrating a control point motion vector (CPMV)derived from a neighboring block.

For example, a maximum of two inherited affine merge candidates may bederived, each of which may be derived based on at least one of leftneighboring blocks and top neighboring blocks. Neighboring blocks forderiving the inherited affine merge mode will be described withreference to FIG. 8 . An inherited affine merge candidate derived basedon a left neighboring block is derived based on at least one of A0 orA1, and an inherited affine merge candidate derived based on a topneighboring block may be derived based on at least one of B0, B1 or B2.In this case, the scan order of the neighboring blocks may be A0 to A1and B0, B1 and B2, but is not limited thereto. For each of the left andtop, an inherited affine merge candidates may be derived based on anavailable first neighboring block in the scan order. In this case,redundancy check may not be performed between candidates derived fromthe left neighboring block and the top neighboring block.

For example, as shown in FIG. 16 , when a left neighboring block A isencoded/decoded in the affine mode, at least one of motion vectors v2,v3 and v4 corresponding to the CP of the neighboring block A may bederived. When the neighboring block A is encoded/decoded through a4-parameter affine model, the inherited affine merge candidate may bederived using v2 and v3. In contrast, When the neighboring block A isencoded/decoded through a 6-parameter affine model, the inherited affinemerge candidate may be derived using v2, v3 and v4.

FIG. 17 is a view illustrating neighboring blocks for deriving aconstructed affine merge candidate.

The constructed affine candidate may mean a candidate having a CPMVderived using a combination of general motion information of neighboringblocks. Motion information for each CP may be derived using spatialneighboring blocks or temporal neighboring blocks of the current block.In the following description, CPMVk may mean a motion vectorrepresenting a k-th CP. For example, referring to FIG. 17 , CPMV1 may bedetermined to be an available first motion vector of motion vectors ofB2, B3 and A2, and, in this case, the scan order may be B2, B3 and A2.CPMV2 may be determined to be an available first motion vector of motionvectors of B1 and B0, and, in this case, the scan order may be B1 andB0. CPMV3 may be determined to be one of motion vectors of A1 and A0,and, in this case, the scan order may be A1 and A0. When TMVP isapplicable to the current block, CPMV4 may be determined as a motionvector of T which is a temporal neighboring block.

After four motion vectors for each CP are derived, a constructed affinemerge candidate may be derived based on this. The constructed affinemerge candidate may be configured by including at least two motionvectors selected from among the derived four motion vectors for each CP.For example, the constructed affine merge candidate may be composed ofat least one of {CPMV1, CPMV2, CPMV3}, {CPMV1, CPMV2, CPMV4}, {CPMV1,CPMV3, CPMV4}, {CPMV2, CPMV3, CPMV4}, {CPMV1, CPMV2} or {CPMV1, CPMV3}in this order. A constructed affine candidate composed of three motionvectors may be a candidate for a 6-parameter affine model. In contrast,a constructed affine candidate composed of two motion vectors may be acandidate for a 4-parameter affine model. In order to avoid the scalingprocess of the motion vector, when the reference picture indices of CPsare different from each other, a combination of related CPMVs may beignored without being used to derive the constructed affine candidate.

When an affine MVP mode applies to a current block, an encoding/decodingapparatus may derive two or more CPMV predictors and CPMVs for thecurrent block and derive CPMV differences based on them. In this case,the CPMV differences may be signaled from the encoding apparatus to thedecoding apparatus. The image decoding apparatus may derive a CPMVpredictor for the current block, reconstruct the signaled CPMVdifference, and then derive a CPMV of the current block based on theCPMV predictor and the CPMV difference.

Meanwhile, only when the affine merge mode or a subblock-based TMVP doesnot apply for the current block, an affine MVP mode may apply for thecurrent block. Meanwhile, the affine MVP mode may be expressed as anaffine CP MVP mode.

When the affine MVP applies for the current block, an affine MVPcandidate list may be configured to derive a CPMV for the current block.In this case, the affine MVP candidate list may include at least one ofan inherited affine MVP candidate, a constructed affine MVP candidate, atranslation motion affine MVP candidate or a zero MVP candidate.

In this case, the inherited affine MVP candidate may mean a candidatederived based on the CPMVs of the neighboring blocks, when theneighboring blocks of the current block are encoded/decoded in an affinemode. The constructed affine MVP candidate may mean a candidate derivedby generating a CPMV combination based on a motion vector of a CPneighboring block. The zero MVP candidate may mean a candidate composedof CPMVs having a value of 0. The derivation method and characteristicsof the inherited affine MVP candidate and the constructed affine MVPcandidate are the same as the above-described inherited affine candidateand the constructed affine candidate and thus a description thereof willbe omitted.

When the maximum number of candidates of the affine MVP candidate listis 2, the constructed affine MVP candidate, the translation motionaffine MVP candidate and the zero MVP candidate may be added when thecurrent number of candidates is less than 2. In particular, thetranslation motion affine MVP candidate may be derived in the followingorder.

For example, when the number of candidates included in the affine MVPcandidate list is less than 2 and CPMV0 of the constructed affine MVPcandidate is valid, CPMV0 may be used as an affine MVP candidate. Thatis, affine MVP candidates having all motion vectors of CP0, CP1, CP2being CPMV0 may be added to the affine MVP candidate list.

Next, when the number of candidates of the affine MVP candidate list isless than 2 and CPMV1 of the constructed affine MVP candidate is valid,CPMV1 may be used as an affine MVP candidate. That is, affine MVPcandidates having all motion vectors of CP0, CP1, CP2 being CPMV1 may beadded to the affine MVP candidate list.

Next, when the number of candidates of the affine MVP candidate list isless than 2 and CPMV2 of the constructed affine MVP candidate is valid,CPMV2 may be used as an affine MVP candidate. That is, affine MVPcandidates having all motion vectors of CP0, CP1, CP2 being CPMV2 may beadded to the affine MVP candidate list.

Despite the above-described conditions, when the number of candidates ofthe affine MVP candidate list is less than 2, a temporal motion vectorpredictor (TMVP) of the current block may be added to the affine MVPcandidate list.

Despite addition of the translation motion affine MVP candidate, whenthe number of candidates of the affine MVP candidate list is less than2, the zero MVP candidate may be added to the affine MVP candidate list.

FIG. 18 is a view illustrating a method of generating an affine MVPcandidate list.

Referring to the flowchart of FIG. 18 , candidates may be added to theaffine MVP candidate list in order of an inherited affine MVP candidate(S1610), a constructed affine MVP candidate (S1620), a translationmotion affine MVP candidate (S1630) and a zero MVP candidate (S1640). Asdescribed above, steps S1620 to S1640 may be performed depending onwhether the number of candidates included in the affine MVP candidatelist is less than 2 in each step.

The scan order of the inherited affine MVP candidates may be equal tothe scan order of the inherited affine merge candidates. However, in thecase of the inherited affine MVP candidate, only neighboring blocksreferencing the same reference picture as the reference picture of thecurrent block may be considered. When the inherited affine MVP candidateis added to an affine MVP candidate list, redundancy check may not beperformed.

In order to derive the constructed affine MVP candidate, only spatialneighboring blocks shown in FIG. 17 may be considered. In addition, thescan order of the constructed affine MVP candidates may be equal to thescan order of the constructed affine merge candidates. In addition, inorder to derive the constructed affine MVP candidate, a referencepicture index of a neighboring block may be checked, and, in the scanorder, a first neighboring block inter-coded and referencing the samereference picture as the reference picture of the current block may beused.

Overview of Subblock-Based TMVP (SbTMVP) Mode

Hereinafter, a subblock-based TMVP mode which is an example of an interprediction mode will be described in detail. According to thesubblock-based TMVP mode, a motion vector field (MVF) for a currentblock may be derived and a motion vector may be derived in units ofsubblocks.

Unlike a conventional TMVP mode performed in units of coding units, fora coding unit to which subblock-based TMVP mode applies, a motion vectormay be encoded/decoded in units of sub-coding units. In addition,according to the conventional TMVP mode, a temporal motion vector may bederived from a collocated block, but, in the subblock-based TMVP mode, amotion vector field may be derived from a reference block specified by amotion vector derived from a neighboring block of the current block.Hereinafter, the motion vector derived from the neighboring block may bereferred to as a motion shift or representative motion vector of thecurrent block.

FIG. 19 is a view illustrating neighboring blocks of a subblock basedTMVP mode.

When a subblock-based TMVP mode applies to a current block, aneighboring block for determining a motion shift may be determined. Forexample, scan for the neighboring block for determining the motion shiftmay be performed in order of blocks of A1, B1, B0 and A0 of FIG. 19 . Asanother example, the neighboring block for determining the motion shiftmay be limited to a specific neighboring block of the current block. Forexample, the neighboring block for determining the motion shift mayalways be determined to be a block A1. When a neighboring block has amotion vector referencing a col picture, the corresponding motion vectormay be determined to be a motion shift. The motion vector determined tobe the motion shift may be referred to as a temporal motion vector.Meanwhile, when the above-described motion vector cannot be derived fromneighboring blocks, the motion shift may be set to (0, 0).

FIG. 20 is a view illustrating a method of deriving a motion vectorfield according to a subblock-based TMVP mode.

Next, a reference block on the collocated picture specified by a motionshift may be determined. For example, subblock based motion information(motion vector or reference picture index) may be obtained from a colpicture by adding a motion shift to the coordinates of the currentblock. In the example shown in FIG. 20 , it is assumed that the motionshift is a motion vector of A1 block. By applying the motion shift tothe current block, a subblock in a col picture (col subblock)corresponding to each subblock configuring the current block may bespecified. Thereafter, using motion information of the correspondingsubblock in the col picture (col subblock), motion information of eachsubblock of the current block may be derived. For example, the motioninformation of the corresponding subblock may be obtained from thecenter position of the corresponding subblock. In this case, the centerposition may be a position of a bottom-right sample among four sampleslocated at the center of the corresponding subblock. When the motioninformation of a specific subblock of the col block corresponding to thecurrent block is not available, the motion information of a centersubblock of the col block may be determined to be motion information ofthe corresponding subblock. When the motion vector of the correspondingsubblock is derived, it may be switched to a reference picture index anda motion vector of a current subblock, similarly to the above-describedTMVP process. That is, when a subblock based motion vector is derived,scaling of the motion vector may be performed in consideration of POC ofthe reference picture of the reference block.

As described above, the subblock-based TMVP candidate for the currentblock may be derived using the motion vector field or motion informationof the current block derived based on the subblock.

Hereinafter, a merge candidate list configured in units of subblocks isdefined as a subblock unit merge candidate list. The above-describedaffine merge candidate and subblock-based TMVP candidate may be mergedto configure a subblock unit merge candidate list.

Meanwhile, a subblock-based TMVP mode flag specifying whether asubblock-based TMVP mode is applicable to a current block may bedefined, which may be signaled at at least one level among higher levelsof the current block such as a sequence, a picture, a slice, a tile, atile group, a brick, etc. For example, the subblock-based TMVP mode flagmay be named sps_sbtmvp_enabled_flag. When the subblock-based TMVP modeis applicable to the current block, the subblock-based TMVP candidatemay be first added to the subblock unit merge candidate list and thenthe affine merge candidate may be added to the subblock unit mergecandidate list. Meanwhile, a maximum number of candidates which may beincluded in the subblock unit merge candidate list may be signaled. Forexample, the maximum number of candidates which may be included in thesubblock unit merge candidate list may be 5.

The size of a subblock used to derive the subblock unit merge candidatelist may be signaled or preset to M×N. For example, M×N may be 8×8.Accordingly, only when the size of the current block is 8×8 or greater,an affine mode or a subblock-based TMVP mode is applicable to thecurrent block.

Hereinafter, an embodiment of a prediction performing method of thepresent disclosure will be described. The following predictionperforming method may be performed in step S410 of FIG. 4 or step S630of FIG. 6 .

A predicted block for a current block may be generated based on motioninformation derived according to a prediction mode. The predicted block(prediction block) may include prediction samples (prediction samplearray) of the current block. When the motion vector of the current blockspecifies a fractional sample unit, an interpolation procedure may beperformed and, through this, prediction samples of the current block maybe derived based on reference samples in units of fractional sampleswithin a reference picture. When affine inter prediction applies to thecurrent block, prediction samples may be generated based on asample/subblock unit MV. When bi-prediction applies, prediction samplesderived through a weighted sum or weighted average (according to phase)of prediction samples derived based on L0 prediction (that is,prediction using MVL0 and a reference picture within a reference picturelist L0) and prediction samples derived based on L1 prediction (that is,prediction using MLV1 and a reference picture within a reference picturelist L1) may be used as the prediction samples of the current block.When applying bi-prediction and a reference picture used for L0prediction and the reference picture used for L1 prediction are locatedin different temporal directions with respect to the current picture(that is, if it corresponds to bi-prediction and bi-directionalprediction), this may be called true bi-prediction.

In an image decoding apparatus, reconstructed samples and areconstructed picture may be generated based on the derived predictionsamples and then an in-loop filtering procedure may be performed. Inaddition, in an image encoding apparatus, residual samples may bederived based on the derived prediction samples and encoding of imageinformation including prediction information and residual informationmay be performed.

Bi-Prediction with CU-Level Weight, BCW

When bi-prediction applies to a current block as described above,prediction samples may be derived based on a weighted average.Conventionally, the bi-prediction signal (that is, bi-predictionsamples) was able to be derived through a simple average of an L0prediction signal (L0 prediction samples) and an L1 prediction signal(L1 prediction samples). That is, bi-prediction samples was derivedthrough an average of the L0 prediction samples based on an L0 referencepicture and MVL0 and L1 prediction samples based on an L1 referencepicture and MVL1. However, according to the present disclosure, whenapplying bi-prediction, a bi-prediction signal (bi-prediction samples)may be derived through a weighted average of the L0 prediction signaland the L1 prediction signal as follows.

P _(bi-pred)(8−w)*P ₀ +w*P ₁+4)>>3  [Equation 3]

In Equation 3 above, P_(bi-pred) denotes a bi-prediction signal(bi-prediction block) derived by a weighted average and P₀ and P₁respectively denote L0 prediction samples (L0 prediction block) and L1prediction samples (L1 prediction block). In addition, (8−w) and wdenote weights applying to P₀ and P₁, respectively.

In generating the bi-prediction signal by the weighted average, fiveweights may be allowed. For example, the weight w may be selected from{−2,3,4,5,10}. For each bi-predicted CU, the weight w may be determinedby one of two methods. As the first method of the two methods, when acurrent CU is not a merge mode (non-merge CU), a weight index may besignaled along with a motion vector difference. For example, a bitstreammay include information on the weight index after information on themotion vector difference. As the second method of the two methods, whenthe current CU is a merge mode (merge CU), the weight index may bederived from neighboring blocks based on a merge candidate index (mergeindex).

Generation of the bi-prediction signal by the weighted average may belimited to apply to only a CU having a size including 256 or moresamples (luma component samples). That is, bi-prediction by the weightedaverage may be performed only with respect to a CU in which a product ofthe width and height of the current block is 256 or more. In addition,the weight w may be used as one of five weights as described above andone of different numbers of weights may be used. For example, accordingto the characteristics of the current image, five weights may be usedfor a low-delay picture and three weights may be used for anon-low-delay picture. In this case, the three weights may be {3,4,5}.

The image encoding apparatus may determine a weight index withoutsignificantly increasing complexity, by applying a fast searchalgorithm. In this case, the fast search algorithm may be summarized asfollows. Hereinafter, an unequal weight may mean that weights applyingto P₀ and P₁ are not equal. In addition, an equal weight may mean thatweights applying to P₀ and P₁ may be equal.

-   -   In the case where an AMVR mode in which resolution of a motion        vector is adaptively changed is applied together, when a current        picture is a low-delay picture, only the unequal weight may be        conditionally checked for each of 1-pel motion vector resolution        and 4-pel motion vector resolution.    -   In the case where an affine mode is applied together and the        affine mode is selected as an optimal mode of the current block,        the image encoding apparatus may perform affine motion        estimation (ME) for each unequal weight.    -   When two reference pictures used for bi-prediction are equal,        only an unequal weight may be conditionally checked.    -   The unequal weight may not be checked when a predetermined        condition is satisfied. The predetermined picture may be based        on a POC distance between a current picture and a reference        picture, a quantization parameter (QP), a temporal level, etc.

A weight index of BCW may be encoded using one context coded bin and oneor more subsequent bypass coded bins. The first context coded binspecifies whether an equal weight is used. When an unequal weight isused, additional bins may be bypass-encoded and signaled. The additionalbins may be signaled to specify which weight is used.

Weighted prediction (WP) is a tool for efficiently encoding an imageincluding fading. According to weighted prediction, weighting parameters(weight and offset) may be signaled for each reference picture includedin each of reference picture lists L0 and L1. Then, when motioncompensation is performed, weight(s) and offset(s) may apply tocorresponding reference picture(s). Weighted prediction and BCW may beused for different types of images. In order to avoid interactionbetween weighted prediction and BCW, a BCW weight index may not besignaled for a CU using weighted prediction. In this case, the weightmay be inferred to be 4. That is, an equal weight may be applied.

In the case of a CU to which a merge mode applies, a weight index may beinferred from neighboring blocks based on a merge candidate index. Thismay apply to both a general merge mode and an inherited affine mergemode.

In the case of a constructed affine merge mode, affine motioninformation may be configured based on motion information of a maximumof three blocks. In this case, the following process may be performed toderive a BCW weight index for a CU using a constructed affine mergemode.

(1) First, the range of the BCW weight index {0,1,2,3,4} may be dividedinto three groups {0}, {1,2,3} and {4}. When the BCW weight index of allCPs are derived from the same group, the BCW weight index may be derivedby step (2) below. Otherwise, the BCW weight index may be set to 2.

(2) When at least two CPs have the same BCW weight index, the same BCWweight index may be allocated as a weight index of a constructed affinemerge candidate. Otherwise, the weight index of the constructed affinemerge candidate may be set to 2.

Bi-Directional Optical Flow (BDOF)

According to the present disclosure, BDOF may be used to refine abi-prediction signal. BDOF is to generate prediction samples bycalculating refined motion information when bi-prediction applies to acurrent block (e.g., CU). Accordingly, a process of calculating refinedmotion information by applying BDOF may be included in theabove-described motion information derivation step.

For example, BDOF may apply at a 4×4 sub-block level. That is, BDOF maybe performed within the current block in units of 4×4 sub-blocks.

BODF may, for example, apply to a CU satisfying the followingconditions.

1) The height of the CU is not 4 and the size of the CU is not 4×8

2) The CU is not in an affine mode or ATMVP merge mode

3) The CU is encoded in a true bi-prediction mode, that is, one of tworeference pictures precedes a current picture in temporal order and theother follows the current picture in temporal order

In addition, BDOF may apply only to a luma component. However, thepresent disclosure is not limited thereto and BDOF may apply to a chromacomponent or both a luma component and a chroma component.

A BDOF mode is based on the concept of optical flow. That is, it isassumed that motion of an object is smooth. When applying BDOF, for each4×4 sub-block, a motion refinement (v_(x), v_(y)) may be calculated. Themotion refinement may be calculated by minimizing a difference betweenan L0 prediction sample and an L1 prediction sample. The motionrefinement may be used to adjust bi-predicted sample values within a 4×4sub-block.

Hereinafter, a process of performing BDOF will be described in greaterdetail.

First, horizontal gradients

$\frac{\partial I^{(k)}}{\partial x}( {i,j} )$

and vertical gradients

$\frac{\partial I^{(k)}}{\partial x}( {i,j} )$

of two prediction signals may be calculated. In this case, k may be 0or 1. The gradients may be calculated as shown in Equation 4 below bydirectly calculating a difference between two adjacent samples.

$\begin{matrix}{{{\frac{\partial I^{(k)}}{\partial x}( {i,j} )} = {( {{I^{(k)}( {{i + 1},j} )} - {I^{(k)}( {{i - 1},j} )}} ) \gg 4}}{{\frac{\partial I^{(k)}}{\partial y}( {i,j} )} = {( {{I^{(k)}( {i,{j + 1}} )} - {I^{(k)}( {i,{j - 1}} )}} ) \gg 4}}} & \lbrack {{Equation}4} \rbrack\end{matrix}$

In Equation 4 above, I^((k))(i,j) denotes a sample value of coordinates(i,j) of a prediction signal in a list k (k=0, 1). For example,I⁽⁰⁾(i,j) may denote a sample value at a position (i,j) in an L0prediction block, and I⁽¹⁾(i,j) may denote a sample value at a position(i,j) in an L1 prediction block.

In Equation 4 above, a difference between two samples is right-shiftedby 4. However, the present disclosure is not limited thereto and theright shift shift1 may be determined based on a bit depth of a lumacomponent. For example, when the bit depth of the luma component isbitDepth, shift1 may be determined to be max(6, bitDepth−6) or maysimply be determined to be a fixed value of 6. In Equation 4 above, forgradient calculation, a difference between two samples was firstcalculated and then right shift operation applied to the difference.However, the present disclosure is not limited thereto and the gradientsmay be calculated by applying right shift operation to two sample valuesand then calculating a difference between right-shifted values.

As described above, after calculating the gradients, auto-correlationand cross-correlation S₁, S₂, S₃, S₅ and S₆ between the gradients may becalculated as follows.

${S_{1} = {{\sum_{{({i,j})} \in \Omega}{{{\psi_{\chi}( {i,j} )} \cdot {\psi_{x}( {i,j} )}}S_{3}}} = {\sum_{{({i,j})} \in \Omega}{{\theta( {i,j} )} \cdot {\psi_{x}( {i,j} )}}}}}{S_{2} = {\sum\limits_{{({i,j})} \in \Omega}{{\psi_{x}( {i,j} )} \cdot {\psi_{y}( {i,j} )}}}}{S_{5} = {{\sum_{{({i,j})} \in \Omega}{{{\psi_{y}( {i,j} )} \cdot {\psi_{y}( {i,j} )}}S_{6}}} = {\sum_{{({i,j})} \in \Omega}{{\theta( {i,j} )} \cdot {\psi_{y}( {i,j} )}}}}}$where $\begin{matrix}{{\psi_{x}( {i,j} )} = {( {{\frac{\partial I^{(1)}}{\partial x}( {i,j} )} + {\frac{\partial I^{(0)}}{\partial x}( {i,j} )}} ) \gg n_{a}}} \\{{\psi_{y}( {i,j} )} = {( {{\frac{\partial I^{(1)}}{\partial y}( {i,j} )} + {\frac{\partial I^{(0)}}{\partial y}( {i,j} )}} ) \gg n_{a}}} \\{{\theta( {i,j} )} = {( {{I^{(1)}( {i,j} )} \gg n_{b}} ) - ( {{I^{(0)}( {i,j} )} \gg n_{b}} )}}\end{matrix}$

where Ω is a 6×6 window around the 4×4 sub-block.

The motion refinement (v_(x), v_(y)) may be derived as follows using theabove-described auto-correlation and cross-correlation between thegradients.

v _(x) =S ₁>0?clip3(−th _(BIO) ′,th _(BIO)′,−((S ₃·2^(n) ^(b) ^(−n) ^(a))>>└log₂ S ₁┘)):0

v _(y) =S ₅>0?clip3(−th _(BIO) ′,th _(BIO)′,−((S ₆·2^(n) ^(b) ^(−n) ^(a)−((v _(x) S _(2,m))<<n _(S) ₂ +v _(x) S _(2,s))/2)>>└log₂ S₅┘)):0  [Equation 6]

where S_(2,m)=S₂>>n_(S) ₂ , S_(2,s)=S₂&(2^(n) ^(S2) −1),th_(BIO)′=2^(13-BD). and └.┘ is the floor function.

Based on the derived motion refinement and gradients, the followingadjustment may be performed with respect to each sample in the 4×4sub-block.

$\begin{matrix}{{b( {x,y} )} = {{{rnd}( {( {v_{x}( {\frac{\partial{I^{(1)}( {x,y} )}}{\partial x} - \frac{\partial{I^{(0)}( {x,y} )}}{\partial x}} )} )/2} )} + {{rnd}( {( {v_{y}( {\frac{\partial{I^{(1)}( {x,y} )}}{\partial y} - \frac{\partial{I^{(0)}( {x,y} )}}{\partial y}} )} )/2} )}}} & \lbrack {{Equation}7} \rbrack\end{matrix}$

Finally, prediction samples pred_(BDOF) of a CU, to which BDOF applies,may be calculated by adjusting the bi-prediction samples of the CU asfollows.

pred_(BDOF)(x,y)=(I ⁽⁰⁾(x,y)+I ⁽¹⁾(x,y)+b(x,y)+o_(offset))>>shift  [Equation 8]

In above Equations, n_(a), n_(b) and n_(S2) may be 3, 6 and 12,respectively. These values may be selected such that a multiplier doesnot exceed 15 bits in the BDOF process and bit-widths of intermediateparameters are maintained within 32 bits.

In order to derive a gradient value, prediction samples I^((k))(i, j) ina list k (k=0, 1) existing outside a current CU may be generated. FIG.21 is a view illustrating a CU extended to perform BDOF.

As shown in FIG. 21 , in order to perform BDOF, rows/columns extendingaround the boundary of a CU may be used. In order to controlcomputational complexity for generating prediction samples outside theboundary, prediction samples in an extended region (white region in FIG.21 ) may be generated using a bilinear filter, and prediction samples ina CU (gray region in FIG. 21 ) may be generated using a normal 8-tapmotion compensation interpolation filter. The sample values at theextended positions may be used only for gradient calculation. Whensample values and/or gradient values located outside the CU boundary arerequired to perform the remaining steps of the BDOF process, nearestneighboring sample values and/or gradient values may be padded(repeated) and used.

When the width and/or height of the CU are greater than 16 luma samples,the corresponding CU may be split into sub-blocks having a width and/orheight of 16 luma samples. The boundary of the sub-blocks may be treatedin the same manner as the above-described CU boundary in the BDOFprocess. A maximum unit size in which the BDOF process is performed maybe limited to 16×16.

When BCW is available for a current block, for example, when a BCWweight index specifies an unequal weight, BDOF may not apply. Similarly,when WP is available for the current block, for example, whenluma_weight_lx_flag for at least one of two reference pictures is 1,BDOF may not apply. In this case, luma_weight_lx_flag may be informationspecifying whether weighting factors of WP for a luma component of lxprediction (x being 0 or 1) is present in a bitstream or informationspecifying whether WP applies to a luma component of lx prediction. Whenthe CU is encoded in an SMVD mode, BDOF may not apply.

Prediction Refinement with Optical Flow (PROF)

Hereinafter, a method of refining a sub-block based affine motioncompensation-predicted block by applying optical flow will be described.Prediction samples generated by performing sub-block based affine motioncompensation may be refined based on a difference derived by an opticalflow equation. Refinement of such prediction samples may be calledprediction refinement with optical flow (PROF) in the presentdisclosure. By PROF, inter prediction of pixel level granularity may beachieved without increasing bandwidth of memory access.

Parameters of an affine motion model may be used to derive a motionvector of each pixel in a CU. However, since pixel based affine motioncompensation prediction causes high complexity and an increase inbandwidth of memory access, sub-block based affine motion compensationprediction may be performed. When sub-block based affine motioncompensation prediction is performed, the CU may be split into 4×4sub-blocks and a motion vector may be determined for each sub-block. Inthis case, the motion vector of each sub-block may be derived from CPMVsof the CU. Sub-block based affine motion compensation has a trad-offrelationship between encoding efficiency and complexity and bandwidth ofmemory access. Since a motion vector is derived in units of sub-blocks,complexity and bandwidth of memory access are reduced but predictionaccuracy is lowered.

Accordingly, motion compensation of refined granularity may be achievedthrough refinement by applying optical flow to sub-block based affinemotion compensation prediction.

As described above, luma prediction samples may be refined by adding adifference derived by an optical flow equation after performingsub-block based affine motion compensation. More specifically, PROF maybe performed in the following four steps.

Step 1) A predicted sub-block I(i,j) is generated by performingsub-block based affine motion compensation.

Step 2) Spatial gradients g_(x)(i,j) and g_(y)(i,j) of the predictedsub-block is calculated at each sample position. In this case, a 3-tapfilter may be used, and filter coefficient may be [−1, 0, 1]. Forexample, the spatial gradients may be calculated as follows.

g _(x)(i,j)=I(i+1,j)−I(i−1,j)

g _(y)(i,j)=I(i,j+1)−I(i,j−1)  [Equation 9]

To calculate the gradients, predicted sub-blocks may extend by one pixelon each side. In this case, to lower memory bandwidth and complexity,pixels of extended boundaries may be copied from closest integer pixelsin a reference picture. Accordingly, additional interpolation for apadding region may be skipped.

Step 3) Luma prediction refinement (ΔI(i,j)) may be calculated by anoptical flow equation. For example, the following equation may be used.

ΔI(i,j)=g _(x)(i,j)*Δv _(x)(i,j)+g _(y)(i,j)*Δv _(y)(i,j)  [Equation 10]

In the above equation, Δv(i,j) denotes a difference between a pixelmotion vector (pixel MV, v(i,j)) calculated at a sample position (i,j)and a sub-block MV of a sub-block, to which a sample (i,j) belongs.

FIG. 22 is a view illustrating a relationship among Δv(i,j), v(i,j) anda sub-block motion vector.

In the example shown in FIG. 22 , for example, a difference between amotion vector v(i,j) at a top-left sample position of a currentsub-block and a motion vector v_(SB) of the current sub-block may berepresented by a thick dotted arrow, and a vector represented by thethick dotted arrow may correspond to Δv(i,j).

Affine model parameters and pixel positions from the center of thesub-block are not changed. Accordingly, Δv(i,j) may be calculated onlyfor a first sub-block and may be reused for the other sub-blocks in thesame CU. Assuming that a horizontal offset and a vertical offset fromthe pixel position to the center of the sub-block are respectively x andy, Δv(x,y) may be derived as follows.

$\begin{matrix}\{ \begin{matrix}{{\Delta{v_{x}( {x,y} )}} = {{c*x} + {d*y}}} \\{{\Delta{v_{y}( {x,y} )}} = {{e*x} + {f*y}}}\end{matrix}  & \lbrack {{Equation}11} \rbrack\end{matrix}$

For 4-parameter affine model,

$\{ \begin{matrix}{c = {f = \frac{v_{1x} - v_{0x}}{w}}} \\{e = {{- d} = \frac{v_{1y} - v_{0y}}{w}}}\end{matrix} $

For 6-parameter affine model,

$\{ \begin{matrix}{c = \frac{v_{1x} - v_{0x}}{w}} \\{d = \frac{v_{2x} - v_{0x}}{h}} \\{e = \frac{v_{1y} - v_{0y}}{w}} \\{f = \frac{v_{2y} - v_{0y}}{h}}\end{matrix} $

In the above, (v_(0x), v_(0y)), (v_(1x), v_(1y)) and (v_(2x), v_(2y))respectively correspond to a top-left CPMV, a top-right CPMV and abottom-left CPMV, and w and h respectively denote the width and heightof the CU.

Step 4) Finally, a final prediction block I′(i,j) may be generated basedon the calculated luma prediction refinement ΔI(i,j) and the predictedsub-block I(i,j). For example, a final prediction block I′ may begenerated as follows.

I′(i,j)=I(i,j)+ΔI(i,j)  [Equation 12]

As described above, by applying BDOF in an inter prediction process torefine a reference sample in a motion compensation process, it ispossible to increase compression performance of an image. BDOF may beperformed in a normal mode. That is, BDOF is not performed in case of anaffine mode, a GPM mode or a CIIP mode.

PROF may be performed on a block encoded in an affine mode, as a methodsimilar to BDOF. As described above, by refining a reference sample ineach 4×4 sub-block through PROF, it is possible to increase compressionperformance of an image.

Since both PROF and BDOF use characteristics of optical flow, whether toapply PROF may be determined according to conditions similar to theapplication conditions of BDOF. According to the present disclosure,various embodiments of WP and BCW may be provided.

In the present disclosure, setting or deriving any information (e.g.,flag) to or as true may mean that the corresponding information isderived as a first value (e.g., ‘1’). In addition, when any informationis set to true, it may indicate that a process (e.g., BDOF, PROF, WP,etc.) specified by the corresponding information is performed.Conversely, in the present disclosure, setting or deriving anyinformation (e.g., flag) to or as false may mean that the correspondinginformation is derived as a second value (e.g., ‘0’). In addition, whenany information is set to false, it may indicate that a processspecified by the corresponding information is not performed.

BDOF may be performed in a motion compensation process by settingbdofFlag to true when various conditions are satisfied as follows.

TABLE 1 - If all of the following conditions are true, bdofFlag is setequal to TRUE.  - sps_bdof_enabled_flag is equal to 1 andslice_disable_bdof_dmvr_flag is equal to 0.  - predFlagL0[ xSbIdx ][ySbIdx ] and predFlagL1[ xSbIdx ][ ySbIdx ] are both equal to 1.  -DiffPicOrderCnt( currPic, RefPicList[ 0 ][ refIdxL0 ] ) *DiffPicOrderCnt( currPic, RefPicList[ 1 ][ refIdxL1 ] ) is less than 0. - MotionModelIdc[ xCb ][ yCb ] is equal to 0.  - merge_subblock_flag[xCb ][ yCb ] is equal to 0.  - sym_mvd_flag[ xCb ][ yCb ] is equal to 0. - ciip_flag[ xCb ][ yCb ] is equal to 0.  - BcwIdx[ xCb ][ yCb ] isequal to 0.  - luma_weight_l0_flag[ refIdxL10 ] and luma_weight_l1_flag[refIdxL1 ] are both equal to 0.  - cbWidth is greater than or equal to8.  - cbHeight is greater than or equal to 8.  - cbHeight * cbWidth isgreater than or equal to 128.  - For X being each of 0 and 1, thepic_width_in_luma_samples and ic_height_in_luma_samples of the referencepicture refPicLX associated with the refIdxLX are equal to thepic_width_in_luma_samples and pic_height_in_luma_samples of the currentpicture, respectively.  - cIdx is equal to 0.

The conditions for performing BDOF described in Table 1 above may bedescribed as in Table 2 below.

TABLE 2 - Information specifying whether BDOF is available at an SPS orslice level specifies “available” - The mode of a current CU is a TRUEbi-prediction mode - The mode of the current CU is not an affine mode, asubblock merge mode, or a SMVD or CIIP mode - WP and BCW do not apply tothe current CU - Both the width and height of the current CU are equalto or greater than 8 and the current CU includes 128 samples - Thewidths and heights of the current picture and the reference picture arethe same - Luma component

However, the conditions for performing BDOF are not limited to theexamples of Tables 1 and 2 above, and some of the conditions may beomitted. In addition, conditions other than the above conditions may beadditionally considered.

When BDOF does not apply to the current block according to the aboveconditions, for example, when the prediction mode of the current blockis an affine mode, PROF is applicable similarly to BDOF. For example,when the prediction mode of the current block is an affine mode, whetherto apply PROF (cbProfFlagLX) may be determined and, when cbProfFlagLX istrue, PROF may be performed.

In BDOF, the offset of the sample is determined using thecharacteristics of optical flow. Accordingly, when the brightness valuesof the reference pictures are different, that is, when applying BCW orweighted prediction (WP), BDOF is not performed. However, PROF may beperformed without considering whether to apply BCW or WP, in spite ofderiving the offset of the sample using the characteristics of opticalflow.

According to an embodiment of the present disclosure, PROF may not applyto a block to which BCW or WP applies, for harmonization between BDOFand PROF from a design point of view. For example, when BcwIdx is not 0,when luma_weight_l0_flag[refIdxL0] is 1 or whenluma_weight_l1_flag[refIdxL1] is 1, information cbProfFlagLX specifyingwhether to apply PROF may be set to false. BcwIdx being not 0 may meanthat BCW applies to the current block, andluma_weight_lX_flag[refIdxLX](X=0 or 1) being 1 may mean that WP appliesto the current block. In the present disclosure, BcwIdx being 0 may meanthat an equal weight applies, that is, a bi-prediction block isgenerated by average sum of an L0 prediction block and an L1 predictionblock. Accordingly, when cbProfFlagLX is set, if BCW or WP applies tothe current block, control may be performed not to apply PROF, by addingthe above conditions.

The following table shows an example of setting cbProfFlagLX accordingto the present disclosure and underlined parts show the addedconditions.

TABLE 3 The variable cbProfFlagLX is derived as follows: - If one ormore of the following conditions are true. cbProfFlagLX is set equal toFALSE. - sps_affine_prof_enabled_flag is equal to 0. -fallbackModeTriggered is equal to 1. - numCpMv is equal to 2 and cpMvLX[1 ][ 0 ] is equal to cpMvLX[ 0 ][ 0 ] and cpMvLX[ 1 ][ 1 ] is equal tocpMvLX[ 0 ][ 1 ]. - numCpMv is equal to 3 and cpMvLX[ 1 ][ 0 ] is equalto cpMvLX[ 0 ][ 0 ] and cpMvLX[ 1 ][ 1 ] is equal to cpMvLX[ 0 ][ 1 ]and cpMvLX[ 2 ][ 0 ] is equal to cpMvLX[ 0 ][ 0 ] and cpMvLX[ 2 ][ 1 ]is equal to cpMvLX[ 0 ][ 1 ]. - BcwIdx[ xCb ][[ yCb ] is not equal to 0. - luma_weight_l0_flag[ refIdxL0 ] is equal to 1 or luma_weight_l1_flag[ refIdxL1 ] is equal to 1. Otherwise, cbProfFlagLXset equal to TRUE.

The following table shows another example of setting cbProfFlagLXaccording to the present disclosure and underlined parts show the addedconditions.

TABLE 4 The variable cbProfFlagLX is derived as follows: - If one ormore of the following conditions are true, cbProfFlagLX is set equal toFALSE. - sps_affine_prof_enabled_flag is equal to 0. -fallbackModeTriggered is equal to 1. - numCpMv is equal to 2 and cpMvLX[1 ][ 0 ] is equal to cpMvLX[ 0 ][ 0 ] and cpMvLX[ 1 ][ 1 ] is equal tocpMvLX[ 0 ][ 1 ]. - numCpMv is equal to 3 and cpMvLX[ 1 ][ 0 ] is equalto cpMvLX[ 0 ][ 0 ] and cpMvLX[ 1 ][ 1 ] is equal to cpMvLX[ 0 ][ 1 ]and cpMvLX[ 2 ][ 0 ] is equal to cpMvLX[ 0 ][ 0 ] and cpMvLX[ 2 ][ 1 ]is equal to cpMvLX[ 0 ][ 1 ]. - BcwIdx[ xCb ][ yCb ] is not equal to 0. - slice_type is equal to P and pps_weighted_pred_flag is equal to 1. - slice_type is equal to B and pps_weighted_bipred_flag is equal to 1.Otherwise, cbProfFlagLX set equal to TRUE.

As described above, whether to apply PROF to the current block may bedetermined. For example, cbProfFlagLX (X=0 or 1) may represent whetherto apply PROF to an L0 prediction direction or an L1 predictiondirection, and, according to the method of Table 3, cbProfFlagLX may bedetermined based on at least one of bcwIdx, luma_wighted_l0_flag and/orluma_wighted_l1_flag. As another example, according to the method ofTable 4, cbProfFlagLX may be determined based on at least one of bcwIdx,slice type, pps_weighted_pred_flag, and/or pps_weighted_bipred_flag. Theslice type specifies a slice type of a current slice, to which a currentpicture belongs, pps_weighted_pred_flag is a picture parameter set (PPS)parameter specifying whether WP applies to a P slice referencing thecorresponding PPS, and pps_weighted_bipred_flag is a picture parameterset (PPS) parameter specifying whether WP applies to a B slicereferencing the corresponding PPS.

According to another embodiment of the present disclosure, PROF mayapply when BCW or WP (explicit weighted prediction) is performed.

In general, a BCW weight index (bcw_idx) is signaled only when WP is notavailable. Accordingly, bcw_idx and weight factors of WP are notsimultaneously signaled. The following table shows an example of asyntax structure for signaling bcw_idx.

TABLE 5 if( sps_bcw_enabled_flag && inter_pred_idc[ x0 ][ y0 ] = =PRED_BI &&  luma_weight_l0_flag[ ref_idx_—l0 [ x0 ][ y0 ] ] = = 0 && luma_weight_l1 flag[ ref_idx_—l1 [ x0 ][ y0 ] ] = = 0 && chroma_weight_l0_flag[ ref_idx_l0 [ x0 ] [ y0 ] ] = = 0 && chroma_weight_l1_flag[ ref_idx_l1 [ x0 ][ y0 ] ] = = 0 &&  cbWidth *cbHeight >= 256 ) bcw_idx[ x0 ][ y0 ] ae(v)

According to Table 5 above, as a condition in which bcw_idx is signaled,whether all weighted prediction flags (e.g., luma_weight_l0_flag,luma_weight_l1_flag, chroma_weight_l0_flag, chroma_weight_l1_flag) ofreference pictures specified by reference picture indices (ref_idx_l0,ref_idx_l1) of the corresponding CU are 0 is checked. Accordingly,according to Table 5, even if WP application flags (e.g.,pps_weighted_pred_flag and/or pps_weighted_bipred_flag) transmitted atPPS are TRUE, when the weighted prediction flag of a specific referencepicture index is 0, bcw_idx may be signaled. That is, according to theexample of Table 5, bcw_idx may be signaled even though WP applies.

FIG. 23 is a flowchart illustrating an example of performing PROF, BCW,WP and/or average sum according to the present disclosure.

Referring to FIG. 23 , first, cbProfFlag (e.g., cbProfFlagLX) specifyingwhether PROF applies for the current block may be derived (S2310).cbProfFlag may be derived based on various methods of the presentdisclosure.

Thereafter, in step S2320, whether cbProfFlag is TRUE may be checkedand, if it is TRUE, PROF may be performed on the current block in stepS2330. PROF may be performed according to the above-described method anda refined prediction sample for the current block may be obtained as aresult of performing PROF. In step S2320, when cbProfFlag is False, stepS2330 may be skipped.

Thereafter, in step S2340, weightedPredFlag specifying whether weightedprediction (WP) applies for the current block may be derived and whetherthe value thereof is TRUE may be checked. A method of derivingweightedPredFlag will be described later. When weightedPredFlag is TRUE,it may be determined that weighted prediction applies for the currentblock, and weighted prediction may be performed on the current block(S2350). Weighted prediction on the current block may be performed basedon weighting parameters (weight and offset) for the reference picture ofthe current block. As described above, the weighting parameters for thereference picture may be explicitly signaled through a bitstream.

When weightedPredFlag is False, it may be determined that weightedprediction does not apply for the current block and whether bcwIdx is 0may be checked (S2360). bcwIdx may be differently derived according tothe prediction mode of the current block. For example, when theprediction mode of the current bock is a skip mode or a merge mode,bcwIdx for the current block may be derived as bcwIdx for a mergecandidate specified by a merge candidate index of the current block.When the prediction mode of the current block is not a merge mode, forexample, an MVP mode, bcwIdx for the current block may be reconstructedby parsing a syntax element bcw_idx signaled through a bitstream. Ifbcw_idx is not signaled through the bitstream, the value of bcwIdx maybe inferred to be 0. When bcwIdx is 0, it may specify that BCW may notapply for the current block. As described above, bcwIdx being 0 may meanthat an equal weight applies, that is, mean that a bi-prediction blockis generated by average sum of an L0 prediction block and an L1prediction block.

In step S2360, when bcwIdx is not 0, it may be determined that BCWapplies for the current block, and BCW may be performed on the currentblock based on a weight specified by bcwIdx (S2370). In step S2360, whenbcwIdx is 0, it may be determined that BCW does not apply for thecurrent block and average sum may be performed on the current block(S2380).

Table 6 shows an example of deriving weightedPredFlag and performing WPor BCW accordingly according to the present disclosure.

TABLE 6 The variable weightedPredFlag is derived as follows:  - Ifslice_type is equal to P, weightedPredFlag is set equal to  pps_weighted_pred_flag.  - Otherwise (slice_type is equal to B),weightedPredFlag is set equal to   pps_weighted_bipred_flag. Thefollowing applies:  - If weightedPredFlag is equal to 0, the arraypbSamples of the prediction   samples is derived by invoking the defaultweighted sample prediction   process as specified in clause 8.5.6.6.2with the coding block width   nCbW, the coding block height nCbH, two(nCbW)x(nCbH) arrays   predSamplesL0 and predSamplesL1, the predictionlist utilization flags   predFlagL0 and predFlagL1, the bi-predictionweight index bcwIdx and   the bit depth bitDepth as inputs.   //defaultweighted prediction Otherwise (weightedPredFlag is equal to 1), thearray pbSamples of the prediction samples is derived by invoking theweighted sample prediction process as specified in clause 8.5.6.6.3 withthe coding block width nCbW, the coding block height nCbH, two(nCbW)x(nCbH) arrays predSamplesL0 and predSamplesL1, the predictionlist utilization flags predFlagL0 and predFlagL1, the reference indicesrefIdxL0 and refIdxL1, the colour component index cIdx and the bit depthbitDepth as inputs. //explicit weighted prediction

According to the method of Table 6, weightedPredFlag may be derivedbased on a slice type of a current slice, to which the current blockbelongs, and a WP application flag (e.g., pps_weighted_pred_flag,pps_weighted_bipred_flag) signaled through a PPS. Specifically, when theslice type of the current block is a P slice, weightedPredflag may bedetermined to be a value of pps_weighted_pred_flag. In addition, whenthe slice type of the current block is a B slice, weightedPredflag maybe determined to be a value of pps_weighted_bipred_flag.

According to the method of Table 6, when weightedPredFlag determined asdescribed above is false, default weighted prediction is performed and,when bcwIdx is not 0, BCW or when bcwIdx is 0, average sum may beperformed. In addition, when weightedPredFlag is true, explicit weightedprediction may be performed based on the signaled weighting parameters.

According to the method of Table 6, weightedPredFlag is determined onlyby the slice type of the current slice and PPS information instead ofthe weighted prediction flags (e.g., luma_weight_l0_flag,luma_weight_l1_flag, chroma_weight_l0_flag, chroma_weight_l1_flag) foreach reference picture, whereas bcw_idx may be signaled based on theweighted prediction flags (e.g., luma_weight_l0_flag,luma_weight_l1_flag, chroma_weight_l0_flag, chroma_weight_l1_flag) foreach reference picture, as shown in Table 5.

Accordingly, even when weightedPredFlag is determined to be TRUEaccording to the method of Table 6, bcw_idx may be signaled. In thiscase, even when bcw_idx is not 0 (default), WP (explicit weightedprediction) is always performed.

The embodiment described with reference to FIG. 23 and Tables 5 and 6has a problem that WP is performed even when bcw_idx is not the default.Hereinafter, another embodiment of the present disclosure for solvingthe above problem will be described.

FIG. 24 is a flowchart illustrating another example of performing PROF,BCW, WP and/or average sum according to the present disclosure.

Referring to FIG. 24 , first, cbProfFlag specifying whether PROF appliesfor a current block may be derived (S2410). cbProfFlag may be derivedbased on various methods of the present disclosure.

Thereafter, in step S2420, whether cbProfFlag is TRUE may be checked,and, when it is TRUE, in step S2430, PROF may be performed on thecurrent block. PROF may be performed according to the above-describedmethod, and a refined prediction sample for the current block may beobtained as a result of performing PROF. In step S2420, when cbProfFlagis False, step S2430 may be skipped.

Thereafter, in step S2440, whether bcwIdx is 0 may be checked. bcwIdxmay be differently derived according to a prediction mode of the currentblock. For example, when the prediction mode of the current bock is askip mode or a merge mode, bcwIdx for the current block may be derivedas bcwIdx for a merge candidate specified by a merge candidate index ofthe current block. When the prediction mode of the current block is nota merge mode, for example, an MVP mode, bcwIdx for the current block maybe reconstructed by parsing a syntax element bcw_idx signaled through abitstream. If bcw_idx is not signaled through the bitstream, the valueof bcwIdx may be inferred to be 0. In step S2440, when bcwIdx is not 0,it may be determined that BCW applies for the current block, and BCW maybe performed on the current block based on a weight specified by bcwIdx(S2450).

In step S2440, when bcwIdx is 0, it may be determined that BCW does notapply for the current block and, thereafter, in step S2460,weightedPredFlag specifying whether weighted prediction (WP) applies forthe current block is TRUE may be checked.

In step S2460, when weightedPredFlag is TRUE, it may be determined thatweighted prediction applies for the current block, and weightedprediction may be performed on the current block (S2470). Weightedprediction on the current block may be performed based on weightingparameters (weight and offset) for the reference picture of the currentblock. As described above, the weighting parameters for the referencepicture may be explicitly signaled through a bitstream.

When weightedPredFlag is False in step S2460, it may be determined thatweighted prediction does not apply for the current block and average summay be performed on the current block (S2480).

According to the embodiment described with reference to FIG. 24 , whenboth explicit weighted prediction (WP) and BCW are applicable for thecurrent block, BCW may preferentially apply.

Table 7 shows another example of deriving weightedPredFlag andperforming WP or BCW accordingly according to the present disclosure.

TABLE 7 The variable weightedPredFlag is derived as follows:  - Ifslice_type is equal to P, weightedPredFlag is set equal to  pps_weighted_pred_flag.  - Otherwise (slice_type is equal to B),weightedPredFlag is set equal to   pps_weighted_bipred_flag. Thefollowing applies:  - If weightedPredFlag is equal to 0 or BcwIdx is notequal to 0, the array   pbSamples of the prediction samples is derivedby invoking the   default weighted sample prediction process asspecified in clause   8.5.6.6.2 with the coding block width nCbW, thecoding block height   nCbH, two (nCbW)x(nCbH) arrays predSamplesL0 and  predSamplesL1, the prediction list utilization flags predFlagL0 and  predFlagL1, the bi-prediction weight index bcwIdx and the bit depth  bitDepth as inputs.   //default weighted prediction  - Otherwise(weightedPredFlag is equal to 1 and BcwIdx is equal to 0),   the arraypbSamples of the prediction samples is derived by invoking   theweighted sample prediction process as specified in clause   8.5.6.6.3with the coding block width nCbW, the coding block height   nCbH, two(nCbW)x(nCbH) arrays predSamplesL0 and   predSamplesL1, the predictionlist utilization flags predFlagL0 and   predFlagL1, the referenceindices refIdxL0 and refIdxL1, the colour   component index cIdx and thebit depth bitDepth as inputs. //explicit weighted prediction

A method of deriving weightedPredFlag is the same in the method of Table6 and the method of Table 7 and thus a detailed description thereof willbe omitted. According to the method of Table 7, when weightedPredFlagdetermined as described above is false or bcwIdx is not 0, defaultweighted prediction may be performed, and BCW or average sum may beperformed according to the value of bcwIdx. In addition, whenweightedPredFlag is true and bcwIdx is 0, explicit weighted predictionmay be performed based on the signaled weighting parameters.

According to the method of Table 7, when weightedPredFlag is true andbcwIdx is not that is, when both explicit weighted prediction (WP) andBCW are applicable for the current block, BCW may preferentially apply.

FIG. 25 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 7.

First, a slice type of a current slice, to which a current blockbelongs, may be determined (S2510). When the slice type is a P slice,weightedPredFlag may be derived as pps_weighted_pred_flag (S2520). Whenthe slice type is a B slice, weightedPredFlag may be derived aspps_weighted_bipred_flag (S2530).

Thereafter, in step S2540, whether weightedPredFlag is 0 or whetherBcwIdx is not 0 may be determined. bcwIdx may be differently derivedaccording to a prediction mode of the current block. For example, whenthe prediction mode of the current bock is a skip mode or a merge mode,bcwIdx for the current block may be derived as bcwIdx for a mergecandidate specified by a merge candidate index of the current block.When the prediction mode of the current block is not a merge mode, forexample, an MVP mode, bcwIdx for the current block may be reconstructedby parsing a syntax element bcw_idx signaled through a bitstream. Ifbcw_idx is not signaled through the bitstream, the value of bcwIdx maybe inferred to be 0.

When weightedPredFlag is 0 or when BcwIdx is not 0, default weightedprediction may be performed (S2550). In this case, when BcwIdx is 0,average sum described in step S2380 or S2480 may be performed. WhenBcwIdx is not 0, BCW described in step S2370 or step S2450 may beperformed.

When weightedPredFlag is not 0 and BcwIdx is 0, explicit weightedprediction may be performed (S2560). In this case, WP described in stepS2350 or step S2470 may be performed.

Table 8 shows another example of deriving weightedPredFlag andperforming WP or BCW accordingly according to the present disclosure.

TABLE 8 The variable weightedPredFlag is derived as follows:  - IfBcwIdx is not equal to 0, weightedPredFlag is set equal to 0.  -Otherwise (BcwIdx is equal to 0). weightedPredFlag is derived as  follows:   - If slice_type is equal to P, weightedPredFlag is setequal to   pps_weighted_pred_flag   Otherwise (slice_type is equal toB), weightedPredFlag is set equal to   pps_weighted_bipred_flag. Thefollowing applies:  - If weightedPredFlag is equal to 0, the arraypbSamples of the prediction   samples is derived by invoking the defaultweighted sample prediction   process as specified in clause 8.5.6.6.2with the coding block width   nCbW, the coding block height nCbH, two(nCbW)x(nCbH) arrays   predSamplesL0 and predSamplesL1, the predictionlist utilization   flags predFlagL0 and predFlagL1, the bi-predictionweight index   bcwIdx and the bit depth bitDepth as inputs.   //defaultweighted prediction Otherwise (weightedPredFlag is equal to 1), thearray pbSamples of the prediction samples is derived by invoking theweighted sample prediction process as specified in clause 8.5.6.6.3 withthe coding block width nCbW, the coding block height nCbH, two(nCbW)x(nCbH) arrays predSamplesL0 and predSamplesL1, the predictionlist utilization flags predFlagL0 and predFlagL1, the reference indicesrefIdxL0 and refIdxL1, the colour component index cIdx and the bit depthbitDepth as inputs. //explicit weighted prediction

According to the method of Table 8, weightedPredFlag may be derived byfurther considering bcwIdx. Specifically, when bcwIdx for the currentblock is not 0, weightedPredFlag may be derived as false. When bcwIdxfor the current block is 0, weightedPredFlag may be derived based on aslice type of a current slice, to which the current block belong, and WPapplication flags (e.g., pps_weighted_pred_flag,pps_weighted_bipred_flag) signaled through a PPS according to the methodof Table 6. According to the method of Table 8, when weightedPredFlagdetermined as described above is false (second value, e.g., 0), defaultweighted prediction is performed, and BCW or average sum may beperformed according to the value of bcwIdx. In addition, whenweightedPredFlag is true (first value, e.g., 1), explicit weightedprediction may be performed based on the signaled weighting parameters.

According to the method of Table 8, when bcwIdx is not 0, by derivingweightedPredFlag as false, BCW may preferentially apply when bothexplicit weighted prediction (WP) and BCW are applicable for the currentblock.

FIG. 26 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 8.

First, whether BcwIdx is not 0 may be determined (S2610). bcwIdx may bedifferently derived according to a prediction mode of a current block.For example, when the prediction mode of the current bock is a skip modeor a merge mode, bcwIdx for the current block may be derived as bcwIdxfor a merge candidate specified by a merge candidate index of thecurrent block. When the prediction mode of the current block is not amerge mode, for example, an MVP mode, bcwIdx for the current block forthe current block may be reconstructed by parsing a syntax elementbcw_idx signaled through a bitstream. If bcw_idx is not signaled throughthe bitstream, the value of bcwIdx may be inferred to be 0.

When BcwIdx is not 0, weightedPredFlag may be derived as 0 (S2620).Thereafter, default weighted prediction may be performed throughdetermination of step S2660 (S2670). Alternatively, step S2620 and stepS2660 may be skipped and step S2670 may be immediately performed. StepS2670 is performed in the same manner as step S2550 and thus a detaileddescription thereof will be omitted.

When BcwIdx is 0, a slice type of a current slice, to which the currentblock belongs, may be determined (S2630). When the slice type is a Pslice, weightedPredFlag may be derived as pps_weighted_pred_flag(S2640). When the slice type is a B slice, weightedPredFlag may bederived as pps_weighted_bipred_flag (S2650).

Thereafter, in step S2660, whether weightedPredFlag is 0 may bedetermined.

When weightedPredFlag is 0, default weighted prediction may be performed(S2670). When weightedPredFlag is not 0, explicit weighted predictionmay be performed (S2680). Step S2670 and step S2680 are respectivelyperformed in the same manner as step S2550 and step S2560 and thus adetailed description thereof will be omitted.

Table 9 shows another example of deriving weightedPredFlag andperforming WP or BCW accordingly according to the present disclosure.

TABLE 9 The variable weightedPredFlag is derived as follows:  - Ifslice_type is equal to P the following applies:   - If one or morefollowing conditions are true, weightedPredFlag is set   equal to 1,   - luma_weight_l0_flag[ refIdxL0 ] is not equal to 0.    -chroma_weight_l0_flag[ refIdxL0 ] is not equal to 0.   - Otherwise,weightedPredFlag is set equal to 0.  - Otherwise (slice_type is equal toB), the following applies:   - If one or more following conditions aretrue, weightedPredFlag is set   equal to 1.    - luma_weight_l0_flag[refIdxL0 ] is not equal to 0.    - luma_weight_l1_flag[ refIdxL1 ] isnot equal to 0.    - chroma_weight_l0_flag[ refIdxL0 ] is not equal to0.    - chroma_weight_l1_flag[ refIdxL1 ] is not equal to 0.   -Otherwise, weightedPredFlag is set equal to 0. The following applies:  -If weightedPredFlag is equal to 0, the array pbSamples of the prediction  samples is derived by invoking the default weighted sample prediction  process as specified in clause 8.5.6.6.2 with the coding block width  nCbW, the coding block height nCbH, two (nCbW)x(nCbH) arrays  predSamplesL0 and predSamplesL1, the prediction list utilization  flags predFlagL0 and predFlagL1, the bi-prediction weight index  bcwIdx and the bit depth bitDepth as inputs.   //default weightedprediction Otherwise (weightedPredFlag is equal to 1), the arraypbSamples of the prediction samples is derived by invoking the weightedsample prediction process as specified in clause 8.5.6.6.3 with thecoding block width nCbW, the coding block height nCbH, two (nCbW)x(nCbH)arrays predSamplesL0 and predSamplesL1, the prediction list utilizationflags predFlagL0 and predFlagL1, the reference indices refIdxL0 andrefIdxL1, the colour component index cIdx and the bit depth bitDepth asinputs. //explicit weighted prediction

According to the method of Table 9, weightedPredFlag may be derived inconsideration of a slice type of a current slice, to which the currentblock belongs, and weighted prediction flags (e.g., luma_weight_l0_flag,luma_weight_l1_flag, chroma_weight_l0_flag, chroma_weight_l1_flag) ofreference pictures specified by reference picture indices (ref_idx_l0,ref_idx_l1) of the current block. Specifically, when the current slice,to which the current block belongs, is a P slice and both weightedprediction flags for an L0 direction (e.g., luma_weight_l0_flag,chroma_weight_l0_flag) are 0, weightedPredFlag may be derived as 0. Inaddition, when the current slice, to which the current block belongs, isa P slice and at least one of the weighted prediction flags for the L0direction (e.g., luma_weight_l0_flag, chroma_weight_l0_flag) is not 0,weightedPredFlag may be derived as 1.

When the current slice, to which the current block belongs, is a B sliceand all weighted prediction flags for an L0 direction and an L1direction (e.g., luma_weight_l0_flag, luma_weight_l1_flag,chroma_weight_l0_flag, chroma_weight_l1_flag) are 0, weightedPredFlagmay be derived as 0. In addition, when the current slice, to which thecurrent block belongs, is a B slice and at least one of the weightedprediction flags for the L0 direction and the L1 direction (e.g.,luma_weight_l0_flag, luma_weight_l1_flag, chroma_weight_l0_flag,chroma_weight_l1_flag) is not 0, weightedPredFlag may be derived as 1.

According to the method of Table 9, when weightedPredFlag determined asdescribed above is false (second value, e.g., 0), default weightedprediction may be performed, and BCW or average sum may be performedaccording to the value of bcwIdx. In addition, when weightedPredFlag istrue (first value, e.g., 1), explicit weighted prediction may beperformed based on the signaled weighting parameters.

According to the method of Table 9, weightedPredFlag is derived based onconditions in which bcw_idx is signaled. That is, by derivingweightedPredFlag as false when bcw_idx is signaled, BCW maypreferentially apply when both explicit weighted prediction (WP) and BCWare applicable for the current block.

FIG. 27 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 9.

First, a slice type of a current slice, to which a current blockbelongs, may be determined (S2710). When the slice type is a P slice,weightedPredFlag may be derived based on luma_weight_l0_flag and/orchroma_weight_l0_flag as described with reference to Table 9 (S2720).When the slice type is a B slice, weightedPredFlag may be derived basedon luma_weight_l0_flag, chroma_weight_l0_flag, luma_weight_l1_flagand/or chroma_weight_l1_flag (S2730).

Thereafter, in step S2740, whether weightedPredFlag is 0 may bedetermined.

When weightedPredFlag is 0, default weighted prediction may be performed(S2750). When weightedPredFlag is not 0, explicit weighted predictionmay be performed (S2760). Step S2750 and step S2760 are performed in thesame manner as step S2550 and step S2560, respectively, and thus adetailed description thereof will be omitted.

Table 10 shows another example of deriving weightedPredFlag andperforming WP or BCW accordingly according to the present disclosure.

TABLE 10 The variable weightedPredFlag is derived as follows:  - Ifslice_type is equal to P the following applies:   - If one or morefollowing conditions are true, weightedPredFlag is set equal   to 1,   - luma_weight_l0_flag[ refIdxL0 ] is not equal to 0.    -chroma_weight_l0_flag[ refIdxL0 ] is not equal to 0.   - Otherwise,weightedPredFlag is set equal to 0.  - Otherwise (slice_type is equal toB). the following applies:   - If one or more following conditions aretrue, weightedPredFlag is set equal   to 1.    - luma_weight_l0_flag[refIdxL0 ] is not equal to 0.    - luma_weight_l1_flag[ refIdxL1 ] isnot equal to 0.    - chroma_weight_l0_flag[ refIdxL0 ] is not equal to0.    - chroma_weight_l1_flag[ refIdxL1 ] is not equal to 0.   -Otherwise, weightedPredFlag is set equal to 0. The following applies:  -If weightedPredFlag is equal to 0 or BcwIdx is not equal to 0, the array  pbSamples of the prediction samples is derived by invoking the default  weighted sample prediction process as specified in clause 8.5.6.6.2with the   coding block width nCbW, the coding block height nCbH, two  (nCbW)x(nCbH) arrays predSamplesL0 and predSamplesL1, the prediction  list utilization flags predFlagL0 and predFlagL1, the bi-predictionweight   index bcwIdx and the bit depth bitDepth as inputs.   //defaultweighted prediction  - Otherwise (weightedPredFlag is equal to 1 andBcwIdx is equal to 0), the array   pbSamples of the prediction samplesis derived by invoking the weighted   sample prediction process asspecified in clause 8.5.6.6.3 with the coding   block width nCbW, thecoding block height nCbH, two (nCbW)x(nCbH)   arrays predSamplesL0 andpredSamplesL1, the prediction list utilization   flags predFlagL0 andpredFlagL1, the reference indices refIdxL0 and   refIdxL1, the colourcomponent index cIdx and the bit depth bitDepth as   inputs. //explicitweighted prediction

A method of deriving weightedPredFlag is the same in the method of Table9 and the method of Table 10 and thus a detailed description thereofwill be omitted. According to the method of Table 10, whenweightedPredFlag determined as described above is false (second value,e.g., 0) or bcwIdx is not 0, default weighted prediction may beperformed, and BCW or average sum may be performed according to thevalue of bcwIdx. In addition, when weightedPredFlag is true (firstvalue, e.g., 1) and bcwIdx is 0, explicit weighted prediction may beperformed based on the signaled weighting parameters.

According to the method of Table 10, weightedPredFlag is derived basedon conditions in which bcw_idx is signaled. That is, by derivingweightedPredFlag as false when bcw_idx is signaled, BCW maypreferentially apply when both explicit weighted prediction (WP) and BCWare applicable for the current block.

In addition, according to the method of Table 10, when weightedPredFlagis true and bcwIdx is not 0, that is, when both explicit weightedprediction (WP) and BCW are applicable for the current block, BCW maypreferentially apply.

FIG. 28 is a flowchart illustrating an example of performing BCW or WPaccording to the method of Table 10.

Step S2810 to step S2830 of FIG. 28 are respectively the same as stepS2710 to step S2730 of FIG. 27 and thus a detailed description thereofwill be omitted.

Referring to FIG. 28 , thereafter, in step S2840, whetherweightedPredFlag is 0 or whether BcwIdx is not 0 may be determined and,default weighted prediction of step S2850 or explicit weightedprediction of step S286 may be performed based on the result ofdetermination. Step S2840 to step S2860 of FIG. 28 are respectively thesame as step S2540 to step S2560 of FIG. 25 and thus a detaileddescription thereof will be omitted.

As described above, the embodiment described with reference to FIG. 23and Tables 5 and 6 has problem that WP is performed even when bcw_idx isnot the default. Hereinafter, another embodiment of the presentdisclosure for solving the above problem will be described.

PROF may apply even when BCW or WP (explicit weighted prediction) isperformed. In general, since bcw_idx is parsed from a bitstream onlywhen WP is not available, BCW and WP shall not exist at the same time.However, as shown in the syntax structure shown in Table to parsebcw_idx from the bitstream, only weighted prediction flags (e.g.,luma_weight_l0_flag, luma_weight_l1_flag, chroma_weight_l0_flag,chroma_weight_l1_flag) of reference pictures specified by referencepicture indices of the current block are checked. In addition, as shownin Table 6, weightedPredFlag is derived based on a slice type of acurrent slice, to which the current block belongs, and WP applicationflags (e.g., pps_weighted_pred_flag, pps_weighted_bipred_flag) signaledthrough a PPS. Accordingly, even when the WP application flag is true,if a weighted prediction flag for a specific reference picture is 0,bcw_idx is parsed. As a result, WP and BCW may simultaneously apply.

Table 11 shows a modified syntax structure in which bcw_idx is parsedaccording to another example of the present disclosure.

TABLE 11 if( sps_bcw_enabled_flag && inter_pred_idc[ x0 ][ y0 ] = =PRED_BI &&   !(slice_type == P && pps_weighted_pred_flag ) &&!(slice_type == B && pps_weighted_bipred_flag ) && cbWidth * cbHeight >=256 )  bcw_idx[ x0 ][ y0 ] ae(v)

In the syntax structure of Table 11, since the parsing condition ofbcw_idx is modified in consideration of the derivation condition ofweightedPredFlag of Table 6, by deriving weightedPredFlag as false whenbcw_idx is parsed and deriving weightedPredFlag as true only whenbcw_idx is not parsed, the case where WP and BCW simultaneously applymay be eliminated. For example, the embodiment described with referenceto FIG. 23 and Tables 5 and 6 may solve the above-described problem byreplacing Table 5 with Table 11.

FIG. 29 is a flowchart illustrating an example of performing BDOF, PROF,BCW, WP, and/or average sum based on values of the bdofFlag, the weightindex BcwIdx, and the weightedPredFlag.

Referring to FIG. 29 , first, bdofFlag specifying whether BDOF appliesfor a current block may be derived (S2910).

In step S2920, when bdofFlag is TRUE, it may be determined that BDOFapplies for the current block, and BDOF may be performed on the currentblock (S2922), and thereafter average sum may be performed on thecurrent block (S2924).

Otherwise, when bdofFlag is False in step S2920, it may be determinedthat BDOF does not apply for the current block and cbProfFlag specifyingwhether PROF applies for a current block may be derived (S2930).cbProfFlag may be derived based on various methods of the presentdisclosure.

Thereafter, in step S2940, whether cbProfFlag is TRUE may be checked,and, when it is TRUE, in step S2950, PROF may be performed on thecurrent block. PROF may be performed according to the above-describedmethod, and a refined prediction sample for the current block may beobtained as a result of performing PROF. In step S2940, when cbProfFlagis False, step S2950 may be skipped.

Thereafter, in step S2960, whether bcwIdx is 0 may be checked. bcwIdxmay be differently derived according to a prediction mode of the currentblock. For example, when the prediction mode of the current bock is askip mode or a merge mode, bcwIdx for the current block may be derivedas bcwIdx for a merge candidate specified by a merge candidate index ofthe current block. When the prediction mode of the current block is nota merge mode, for example, an MVP mode, bcwIdx for the current block maybe reconstructed by parsing a syntax element bcw_idx signaled through abitstream. If bcw_idx is not signaled through the bitstream, the valueof bcwIdx may be inferred to be 0. In step S2960, when bcwIdx is not 0,it may be determined that BCW applies for the current block, and BCW maybe performed on the current block based on a weight specified by bcwIdx(S2962).

In step S2960, when bcwIdx is 0, it may be determined that BCW does notapply for the current block and, thereafter, in step S2970,weightedPredFlag specifying whether weighted prediction (WP) applies forthe current block is TRUE may be checked.

In step S2970, when weightedPredFlag is TRUE, it may be determined thatweighted prediction applies for the current block, and weightedprediction may be performed on the current block (S2972). Weightedprediction on the current block may be performed based on weightingparameters (weight and offset) for the reference picture of the currentblock. As described above, the weighting parameters for the referencepicture may be explicitly signaled through a bitstream.

When weightedPredFlag is False in step S2970, it may be determined thatweighted prediction does not apply for the current block and average summay be performed on the current block (S2974).

According to the embodiment described with reference to FIG. 29 , whenboth explicit weighted prediction (WP) and BCW are applicable for thecurrent block, BCW may preferentially apply.

While the exemplary methods of the present disclosure described aboveare represented as a series of operations for clarity of description, itis not intended to limit the order in which the steps are performed, andthe steps may be performed simultaneously or in different order asnecessary. In order to implement the method according to the presentdisclosure, the described steps may further include other steps, mayinclude remaining steps except for some of the steps, or may includeother additional steps except for some steps.

In the present disclosure, the image encoding apparatus or the imagedecoding apparatus that performs a predetermined operation (step) mayperform an operation (step) of confirming an execution condition orsituation of the corresponding operation (step). For example, if it isdescribed that predetermined operation is performed when a predeterminedcondition is satisfied, the image encoding apparatus or the imagedecoding apparatus may perform the predetermined operation afterdetermining whether the predetermined condition is satisfied.

The various embodiments of the present disclosure are not a list of allpossible combinations and are intended to describe representativeaspects of the present disclosure, and the matters described in thevarious embodiments may be applied independently or in combination oftwo or more.

Various embodiments of the present disclosure may be implemented inhardware, firmware, software, or a combination thereof. In the case ofimplementing the present disclosure by hardware, the present disclosurecan be implemented with application specific integrated circuits(ASICs), Digital signal processors (DSPs), digital signal processingdevices (DSPDs), programmable logic devices (PLDs), field programmablegate arrays (FPGAs), general processors, controllers, microcontrollers,microprocessors, etc.

In addition, the image decoding apparatus and the image encodingapparatus, to which the embodiments of the present disclosure areapplied, may be included in a multimedia broadcasting transmission andreception device, a mobile communication terminal, a home cinema videodevice, a digital cinema video device, a surveillance camera, a videochat device, a real time communication device such as videocommunication, a mobile streaming device, a storage medium, a camcorder,a video on demand (VoD) service providing device, an OTT video (over thetop video) device, an Internet streaming service providing device, athree-dimensional (3D) video device, a video telephony video device, amedical video device, and the like, and may be used to process videosignals or data signals. For example, the OTT video devices may includea game console, a blu-ray player, an Internet access TV, a home theatersystem, a smartphone, a tablet PC, a digital video recorder (DVR), orthe like.

FIG. 30 is a view showing a content streaming system, to which anembodiment of the present disclosure is applicable.

As shown in FIG. 30 , the content streaming system, to which theembodiment of the present disclosure is applied, may largely include anencoding server, a streaming server, a web server, a media storage, auser device, and a multimedia input device.

The encoding server compresses contents input from multimedia inputdevices such as a smartphone, a camera, a camcorder, etc. into digitaldata to generate a bitstream and transmits the bitstream to thestreaming server. As another example, when the multimedia input devicessuch as smartphones, cameras, camcorders, etc. directly generate abitstream, the encoding server may be omitted.

The bitstream may be generated by an image encoding method or an imageencoding apparatus, to which the embodiment of the present disclosure isapplied, and the streaming server may temporarily store the bitstream inthe process of transmitting or receiving the bitstream.

The streaming server transmits the multimedia data to the user devicebased on a user's request through the web server, and the web serverserves as a medium for informing the user of a service. When the userrequests a desired service from the web server, the web server maydeliver it to a streaming server, and the streaming server may transmitmultimedia data to the user. In this case, the content streaming systemmay include a separate control server. In this case, the control serverserves to control a command/response between devices in the contentstreaming system.

The streaming server may receive contents from a media storage and/or anencoding server. For example, when the contents are received from theencoding server, the contents may be received in real time. In thiscase, in order to provide a smooth streaming service, the streamingserver may store the bitstream for a predetermined time.

Examples of the user device may include a mobile phone, a smartphone, alaptop computer, a digital broadcasting terminal, a personal digitalassistant (PDA), a portable multimedia player (PMP), navigation, a slatePC, tablet PCs, ultrabooks, wearable devices (e.g., smartwatches, smartglasses, head mounted displays), digital TVs, desktops computer, digitalsignage, and the like.

Each server in the content streaming system may be operated as adistributed server, in which case data received from each server may bedistributed.

The scope of the disclosure includes software or machine-executablecommands (e.g., an operating system, an application, firmware, aprogram, etc.) for enabling operations according to the methods ofvarious embodiments to be executed on an apparatus or a computer, anon-transitory computer-readable medium having such software or commandsstored thereon and executable on the apparatus or the computer.

INDUSTRIAL APPLICABILITY

The embodiments of the present disclosure may be used to encode ordecode an image.

1. An image decoding method performed by an image decoding apparatus,the image decoding method comprising: receiving a bitstream; deriving,based on the received bitstream, a first flag for Bi-Directional OpticalFlow (BDOF) on a current block of a picture; based on the first flagspecifying that the BDOF is to be applied to the current block:performing a BDOF process on the current block; based on the first flagspecifying that the BDOF is not to be applied to the current block:checking, based on the received bitstream, (i) a second flag forweighted prediction on the current block and (ii) a weight index BcwIdxfor performing bi-prediction with CU-level weight (BCW) for the currentblock, and based on the second flag and the weight index BcwIdx,determining whether to perform default weighted prediction or explicitweighted prediction on the current block; wherein the default weightedprediction is performed on the current block, based on the second flagbeing equal to 0 or the weight index BcwIdx not being equal to 0,wherein the explicit weighted prediction is performed on the currentblock, based on the second flag being equal to 1 and the weight indexBcwIdx being equal to 0, and wherein the second flag is determinedindependently of weight prediction flags for a reference picture of thecurrent block; wherein the default weighted prediction performs theaverage sum on the current block based on the weight index BcwIdx beingequal to 0, wherein the default weighted prediction performs the BCW onthe current block based on the weight index BcwIdx not being equal to 0,and wherein the explicit weighted prediction is performed based onweighting parameters (weight and offset) for a reference picture of thecurrent block.
 2. The image decoding method of claim 1, wherein thesecond flag is differently determined based on a slice type of a currentslice, to which the current block belongs.
 3. The image decoding methodof claim 2, wherein the second flag is derived as a value ofpps_weighted_pred_flag signaled at a picture parameter set (PPS), basedon the slice type of the current slice being a P slice, and wherein thesecond flag is derived as a value of pps_weighted_bipred_flag signaledat the PPS, based on the slice type of the current slice being a Bslice.
 4. The image decoding method of claim 1, wherein the weight indexBcwIdx is derived based on a syntax element bcw_idx signaled through thebitstream, and wherein the weight index BcwIdx is derived as 0 based onthe syntax element bcw_idx being not present in the bitstream.
 5. Theimage decoding method of claim 4, wherein the syntax element bcw_idx isparsed from the bitstream based on a weighted prediction flag of areference picture of the current block.
 6. The image decoding method ofclaim 4, wherein the syntax element bcw_idx is parsed from the bitstreambased on all weighted prediction flags of a reference picture of thecurrent block being equal to
 0. 7. The image decoding method of claim 1,wherein the weighting parameters are explicitly signaled through thebitstream.
 8. An image encoding method performed by an image encodingapparatus, the image encoding method comprising: deriving a first flagfor Bi-Directional Optical Flow (BDOF) on a current block of a picture;based on the first flag specifying that the BDOF is to be applied to thecurrent block: performing a BDOF process on the current block; based onthe first flag specifying that the BDOF is not to be applied to thecurrent block: checking (i) a second flag for weighted prediction on thecurrent block and (ii) a weight index BcwIdx for performingbi-prediction with CU-level weight (BCW) for the current block; andbased on the second flag and the weight index BcwIdx, determiningwhether to perform default weighted prediction or explicit weightedprediction on the current block, wherein the default weighted predictionis performed on the current block, based on the second flag being equalto 0 or the weight index BcwIdx not being equal to 0, wherein theexplicit weighted prediction is performed on the current block, based onthe second flag being equal to 1 and the weight index BcwIdx being equalto 0, and wherein the second flag is determined independently of weightprediction flags for a reference picture of the current block; encodinginformation related to the first flag, the second flag and the weightindex BcwIdx, wherein the default weighted prediction performs theaverage sum on the current block based on the weight index BcwIdx beingequal to 0, wherein the default weighted prediction performs the BCW onthe current block based on the weight index BcwIdx not being equal to 0,and wherein the explicit weighted prediction is performed based onweighting parameters (weight and offset) for a reference picture of thecurrent block.
 9. A method for transmitting a bitstream, comprising:transmitting a bitstream generated by the steps of: deriving a firstflag for Bi-Directional Optical Flow (BDOF) on a current block of apicture; based on the first flag specifying that the BDOF is to beapplied to the current block: performing a BDOF process on the currentblock; based on the first flag specifying that the BDOF is not to beapplied to the current block: checking (i) a second flag for weightedprediction on the current block and (ii) a weight index BcwIdx forperforming bi-prediction with CU-level weight (BCW) for the currentblock; and based on the second flag and the weight index BcwIdx,determining whether to perform default weighted prediction or explicitweighted prediction on the current block, wherein the default weightedprediction is performed on the current block, based on the second flagbeing equal to 0 or the weight index BcwIdx not being equal to 0,wherein the explicit weighted prediction is performed on the currentblock, based on the second flag being equal to 1 and the weight indexBcwIdx being equal to and wherein the second flag is determinedindependently of weight prediction flags for a reference picture of thecurrent block; encoding information related to the first flag, thesecond flag and the weight index BcwIdx, wherein the default weightedprediction performs the average sum on the current block based on theweight index BcwIdx being equal to 0, wherein the default weightedprediction performs the BCW on the current block based on the weightindex BcwIdx not being equal to 0, and wherein the explicit weightedprediction is performed based on weighting parameters (weight andoffset) for a reference picture of the current block.
 10. Anon-transitory computer-readable medium storing a bitstream generated bythe method of claim 8.